Friday, April 1, 2011

GIT CheatSheet

If you are looking for a cheat sheet which would help you in working around with git, see the commands below. Alternatively you could use TortoiseGIT which gives a GUI and makes life simple.

GIT commands:
To clone the project:
git clone url (example: git clone git://anongit.freedesktop.org/git/pixman.git)
This would create pixman directory with a .git folder inside it.
to create branch
git branch -b images_gifdecoder_mynameiskhan
 or
git branch branch_name
git checkout branch_name
NOTE: branch naming convention -- feature_details_name - this will help to 
have unique branch names
List of branches on your repository
git branch  ----------------> '*' indicates the current branch
List of branches on server repository as well
git branch -a
Delete a branch
git branch -d branch_name
Track a remote branch
git branch --track pixman_naiem_trial remotes/origin/pixman_naiem_trial
Know the status
git status
Reset all changes:
git checkout -f
See most recent commit
git show
Commit only few files:
git commit path/to/some/files
Merge
git merge branchname
merge branchname to current branch
Resolving a merge
git status
edit the files with problem and then do staging by git add
Stashing changes
git stash "work in progress for foo feature"
git stash apply
Revert changes
git reset --hard
 

2 comments: