In this article I will log useful git commands and functions.

Useful Commands

Description  GIT command 
Write difference between two commits or branches into a text file.  git diff {commit1} {commit2} > diff.txt 
 Merging another branch into a currently checked out branch. git merge {branch name}

Useful functions

Below section lists some tricks, which I found helpful.

GIT ignore

In order to ignore files or directories in GIT you can create a text file called ".gitignore" in the same directory as the git repository is located.

In windows you first create a text file and then you rename it to ".gitignore.". It is important to provide a dot at the beginning as well as the end of the files name. Else Windows won't allow renaming the file to ".gitignore".

Then save the directories and files you want to ignore into the created text file ".gitignore". Below an example.


If you want to ignore files of a certain type you can use wildcards as following example shows.


The exclamation mark is stating for example that all xml files in directory src/test should NOT be ignored.
All other xml files in any directory will be ignored.