Git Commands – Quick Reference



These common Git commands are listed here for quick reference.

Create a new branch in Git


$ git branch Branch_Name


See all branches:


$ git branch -a


Checkout a branch in Git


$ git checkout Branch_Name


Delete all directories named “_vti_cnf”


$ find . -type d -name '_vti_cnf' -print0 | xargs -0 git rm -r --


Add files to be committed: add only files created or modified, not those deleted.


$ git add .


Add files to be committed: add only files deleted or modified, not those created.


$ git add -u


Add files to be committed: add all files, deleted, modified, or created.


$ git add -A


Remove a directory from a Git repository


$ git rm -r -f Directory_Name


Remove existing files from a Git repository


$ git rm -r --cached File_Name


Undo a previous commit


$ git revert HEAD


Delete a branch in Git, locally


$ git branch -D work


Delete a remote branch (i.e. at GitHub.com)


$ git push origin --delete work


List all existing tags


$ git tag


Tag a new release version


$ git tag -a 1.3.6 -m "Tagging 1.3.6"


Tag the new release on GitHub.com


$ git push origin --tags

No comments:

Post a Comment