Git CheatSheet

CheatSheet for git commands:

# clone a github repository
git clone

# changed files in working dir
git status

# show the change log
git log

# stage all current changes for next commit
git add    .

# stage <file> for next commit
git add -p <file>

# commit previously staged files
git commit -m "my msg"

# stage current changes then commit (excludes new files)
git commit -a

# push commited changes to origin master
git push

# only fetch changes from remote
git fetch

# merge changes from origin
git merge

# fetch from remote and merge
git pull

# create a new branch 'abc'
git branch abc

# switch to using branch 'abc'
git checkout abc

# overwrite local changes and remove all local changes
git fetch origin  
git reset --hard origin/master  

Baldeep Hira

bay area programmer working on mobile/tablet/web apps and enterprise cloud apps; ui/ux, html5 and everything else for a prettier web and world

  • San Francisco Bay Area
comments powered by Disqus