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 user.name "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
C:\Users\Chris\src\java_3rdParty\
Project level files
.classpath
overview.html
.project
ant.properties
README.rest
.gitignore
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.
Syntax
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.
Example
git ls-files --others --exclude-from=.git/info/exclude
Generated Files
doc\\user\\v1\\build
Personal Files
doc\\CJB_Custom_Dictionary.txt
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:
;%MERGEHOME%\
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.
- [diff]
- tool = bc
- [difftool “bc”]
- path = C:\Program Files (x86)\Beyond Compare 4\BComp.exe
- [merge]
- 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
Merge
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.