Skip to content

Instantly share code, notes, and snippets.

@liutingdu
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liutingdu/065989bf21df2202630b to your computer and use it in GitHub Desktop.
Save liutingdu/065989bf21df2202630b to your computer and use it in GitHub Desktop.
Useful git commands

##Branch Management show all branches git branch -v git branch -a
delete branch git branch -d
clone a single branch git clone -b mybranch --single-branch git://sub.domain.com/repo.git

##Discard Changes / Commits Discard all local changes and commitsgit reset --hard origin/master

##Manage commit histories Remove all commit hstories for file contains sensitive data:
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch Rakefile' --prune-empty --tag-name-filter cat -- --all
git push origin --force --all

Merge the previous two commits into one: git reset --soft HEAD~2 and then re-commit

##Other Ignore file mode changes: git config core.fileMode false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment