To see the history for line 13 in the file file.xml:

$ git log --format=format:%H  file.xml | xargs -L 1 git blame file.xml -L 13,13

To see the files in a commit:

$ git diff-tree --no-commit-id --name-only -r <commit-id>



$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get install git


On Windows:

> git config --global difftool.gvimdiff.path "C:\Program Files (x86)\Vim\vim74\gvim.exe"
> git config --global mergetool.gvimdiff.path "C:\Program Files (x86)\Vim\vim74\gvim.exe"
> git config --global diff.tool gvimdiff
> git config --global merge.tool gvimdiff

Commit Messages

Merge vs. Rebase

Workflow models

Credential Helper


$ git config --global credential.helper "cache --timeout=3600"


$ git config --global credential.helper store

Note that this will store your creds in plaintext in ~/.git-credentials.


$ git config --global credential.helper wincred


core.autocrlf = false

This is the default, but most people are encouraged to change this immediately. The result of using false is that Git doesn?t ever mess with line endings on your file. You can check in files with LF or CRLF or CR or some random mix of those three and Git does not care. This can make diffs harder to read and merges more difficult. Most people working in a Unix/Linux world use this value because they don?t have CRLF problems and they don?t need Git to be doing extra work whenever files are written to the object database or written out into the working directory.

core.autocrlf = true

This means that Git will process all text files and make sure that CRLF is replaced with LF when writing that file to the object database and turn all LF back into CRLF when writing out into the working directory. This is the recommended setting on Windows because it ensures that your repository can be used on other platforms while retaining CRLF in your working directory.

core.autocrlf = input

This means that Git will process all text files and make sure that CRLF is replaced with LF when writing that file to the object database. It will not, however, do the reverse. When you read files back out of the object database and write them into the working directory they will still have LFs to denote the end of line. This setting is generally used on Unix/Linux/OS X to prevent CRLFs from getting written into the repository. The idea being that if you pasted code from a web browser and accidentally got CRLFs into one of your files, Git would make sure they were replaced with LFs when you wrote to the object database.

Use .gitattributes to specify the line endings for a specific file:

vimfiles/notes.txt text eol=lf


To add a tag:

$ git tag new-tag

To list tags:

$ git tag

To push tags:

$ git push origin --tags

Init bare repo on UNC path

git init --bare \\server\path\repo.git
git clone //server/path/repo.git


'git log' [<options>] [<revision range>] [[\--] <path>...]

Commonly Ignored Files

#OS junk files

#Visual Studio files



#Project files

#Subversion files

# Office Temp Files



# Java class files

# android: built application files

# android: files for the dex VM

# android: generated files

# android: Local configuration file (sdk path, etc)

# Eclipse project files
# .project

# Proguard folder generated by Eclipse

# Intellij project files

Git Grep

  • git grep text (ignores .ignore files)
  • git log –grep=text (filter commits with text in the message)
  • git log -Stext (pickaxe: find text that was added or removed by a commit)