My git process

I’m starting to use git a lot more now I am commiting code to github. Just for my reference I do the following for each commit

git init

required only if you are creating a git repository from scratch.

git status

This displays the files deleted and modified and not tracked.

git add .

add . adds any new (untracked) files to the git repository so now they are tracked. Make sure you include the period as this tells it to go through the whole directory and subdirectories.

git commit -a

This initiates a commit. git asks for a commit message, which you type in and then do Ctrl+x to save . It then asks you to save the buffer, you enter “y” to continue, then hit enter to confirm the file to save the git edits to. The command updates the local repository with all the physical changes on the disk so deletes files that aren’t there, adds new files, and updates files that have changed.

git push origin master

this updates the remote repository – in this case my github repostitory. You may have to set this up initially in github by creating a new repo and using the supplied url to set it up locally:

git remote add origin

If I make a mistake on the original git repository (e.g. do not include all the directories I choose to ignore in .gitignore) I just delete the.git directory and start over. This can’t be done I guess if you have a remote repository set up.

SQL Server merge 2 DateTime fields

At work we need to merge a datetime field with no time element and a datetime field with no time element – there are two solutions on this stack overflow post depending on what is there in the original data. Thes easiest is the first solution. You can add the fields together as DateTime are stored as floating point values. I used the second as I could not guarantee the conditions required for the first:

SELECT DATEADD(day, 0, DATEDIFF(day, 0, your_date_column)) + DATEADD(day, 0 - DATEDIFF(day, 0, your_time_column), your_time_column) FROM your_table