Monday, October 15, 2012

My git cheat sheet


  • Update commit message
    git commit --amend -m "correct commit message"
  • Create and start track remote branch
    git checkout -b branch_name
    git push origin branch_name
    git branch --set-upstream branch_name origin/branch_name
  • Delete a commit you a sitting on (not yet pushed)
    git reset --hard HEAD~1
  • Delete remote branch and stop track it
    git push origin --delete branch_name
    git branch -d branch_name
    git remote prune origin
  • Reset the index and working tree
    git reset --hard
  • Find all branches which can be safely deleted, since those branches are fully contained by HEAD
    git branch -r --merged

No comments:

Post a Comment