Git installation

After you Install Git

You must configure your Git installation for first use. For more information, see Getting Started – First-Time Git Setup.

Setup your identity

Configure your username.

git config --global "John Doe"

Give the executables admin privileges

Edit the Properties of the following two executable files, and give them Admin Privileges for All Users.

C:\Program Files\Git\bin\sh.exe
C:\Program Files\Git\mingw64\bin\wish.exe

Add the git bash icon to the taskbar

Check to see if there is already an icon for it on your desktop. If there is, then right-click it, and select Display on Taskbar.

Add the git GUI icon to the taskbar

Note: If you already have a git bash open, then simply type “git gui” to start the Git GUI. Type “gitk” to start the Git Branch Visualizer.

Target: “C:\Program Files\Git\bin\wish.exe” “C:\Program Files\Git\libexec\git-core\git-gui”

Start in: %GITSOURCE%

Set the default.push behavior

Note: If you’ve done this before, then you don’t have to do it again.

Set this to simple, which will push the current branch to its upstream counterpart, but only if there is an upstream counterpart.

git config --global push.default simple

Files to store in git

For java 3rd party


Project level files


There are two places that you can store ignore lists.

  • In a file named “.gitignore” in the project’s root directory. This is for files that no one on the team wants tracked.
  • In a file named “exclude” in the project’s $GIT_DIR/info/exclude. This is for files that you want ignored for your own personal files, that you don’t want to share with the rest of the team.


In Git, back-slashes (\) are used to escape git’s special symbols (e.g., ! becomes \! for a filename spec that begins with a bang).

In Git, forward-slashes (/) are used to denote a level in a path structure. You don’t have to include the trailing slash in a folder name. Git ignores the directory, and everything it contains. I.e., the rest of the branch.

To exclude all files of a particular type, you must precede the filespec with an asterisk. E.g., “.pyc” won’t work. “*.pyc” will work.


git ls-files --others --exclude-from=.git/info/exclude

Generated Files


Personal Files


Merge changes from another branch into this branch

git merge --no-ff scrub_verify_code

Push changes from a local branch to the same branch on the remote

git push origin feature/api_doc

Note: You must specify the branch because if you don’t, then Git attempts to push all branches.

Setup beyond compare as the external merge tool

Note: This only works from the Git bash. I was hoping to get it to work from the Git GUI, but I kept getting an error when I right-clicked the diff pane, and select Merge.

Create a new environment variable

MERGEHOME=C:\Program Files (x86)\Beyond Compare 4

Path it:


Note: If you use the Git for Windows’ bash command prompt instead of the default Windows command prompt, then you need to escape the $ character with .

Upadate the global .gitconfig file

Update your user configuration file (%USERPROFILE%.gitconfig) with the following information.

tool = bc
[difftool “bc”]
path = C:\Program Files (x86)\Beyond Compare 4\BComp.exe
tool = bc
[mergetool “bc”]
cmd = “C:\Program Files (x86)\Beyond Compare 4\BComp.exe” “$LOCAL” “$REMOTE” “$BASE” “$MERGED”

Running a merge using beyond compare

You need to merge when you pull (or merge) the latest version of the master branch into your branch. Git downlads a copy of the remote’s copy of the current branch, and then adds it to your repo. In your repo, it’s just another branch, and it’s named “upstream/master”.

git fetch upstream


git merge upstream/master

When you execute this command from the Git Bash:

git mergetool

To launch a 3-way merge on a particular file, use the command:

git mergetool foofile.txt

What happens when you run a merge

When you launch the Git Mergetool, the Beyond Compare 4 GUI appears, with the four 3-way merge panes loaded with:

Left Pane
Your version.
Middle Pane
The last version before you made your changes, and before it was changed in the remote.
Right Pane
The version in the remote.
Bottom Pane
Your new version – which will contain the merged content.

Leave a Reply