Git Commands

git config --global "John Doe" git config --global

Getting Help
git help <verb> git <verb> --help man git-<verb>

Getting a Git Repository
Initializing a Repository in an Existing Directory
git init

Start tracking files
git git git git add *.c add . add README commit -m 'initial project version'

Cloning an Existing Repository
git clone git:// git clone git:// mygrit

Recording Changes to the Repository git git git git git git git status log log --pretty=oneline diff commit commit -am 'reason for commit' commit --amend

List branches
git branch With last commit info: git branch -v

Creating a new branch
git checkout -b hotfix Short for: git branch hotfix git checkout hotfix

git checkout master git merge hotfix Show merged branches: git branch merged Show branches yet to be merged: git branch --no-merged

Delete a branch
git branch -d hotfix


Working with Remotes
Listing remotes
git remotes git remote show origin

Listing remotes with URL
git remote -v

Pushing to remotes
git push origin master

Sign up to vote on this title
UsefulNot useful