To see the list of git commands
git helpTo see help on a git command
git help COMMAND_NAMEConfigure your GIT first time
git config --global user.name "Your Full Name" git config --global user.email "name@therapservices.net"Configure your GIT to get colorize output
git config --global color.status auto git config --global color.diff auto git config --global color.branch autoClone your project
git clone git://masum/therap therap
Clone a bare repository for publishing (for team leads):
git clone --bare git://masum/therap therap
Add release branch
git branch --track release origin/release
Delete branch
git branch -D BRANCH_NAME
Add other’s repo as remote branch
git remote add -t master -t release otherperson git://otherperson/therap
Fetch/merge master from otherperson
git checkout master git fetch git://otherperson master:master git merge otherperson/master
See all the tags (usually used to mark releases)
git tag -l
See list of all commits from a particular release tag to now
git log --no-merges..HEAD git log --no-merges v7.2.4..HEAD
See list of all commits between two release tags
git log --no-merges.. git log --no-merges v7.2.3..v7.2.4
See which files you are changing
git log --stat
See change details too
git log -p --stat
Viewing the changes you have made since last commit
1) git status 2) git diff 3) git diff --cached 4) git diff HEAD
- See status of all files changed or added
- See the changes that you have made but not added, changes in a file after the last git add is also
- See the changes that you have added to commit, changes done in working directory but not added are not shown
- See all changes you have made since last commit (HEAD)
1) git add filePath 2) git add filePattern 3) git add . 4) git add web/WEB-INF/ 5) git add *.java
- Adding a single file
- Adding multiple files
- Adding all files you have changed, give the command from your project root
- Adding all files under web/WEB-INF directory
- Adding all changes to java files
Reset/Undo Changes of a file
git checkout HEAD filepath or git checkout -- filepath
Undo Commit and Keep Changes:
git reset --soft HEAD^
To see who, when added/modified each line of a file
git blame
Make changes in commit message before pulled by anyone else
git commit --amend
More information on git: http://git-scm.com/