Git cheat sheet

  • git config –global user.name “Firstname Lastname”
  • git config –global user.email “your_email@youremail.com”
  • .gitignore in git directory tells which files not to add/commit (.swp files…)
  • git clean -n -d (dry run look for files that are untracked)  git clean -d -f (remove them)
  • git commit –amend ( add on to the last commit (forgot a file.) )
  • git rm –cached (delete the file on git, but leave it local)
  • git blame <file> : Show each line of a file, and who checked in the lastest change to that line of the file.
  • git branch <branchname> then git checkout <branchname> to switch to it
  • git merge <branchname> to merge into head
  • git log HEAD~4 : look at the last 4 commits
  • git rebase -i HEAD~<X>  take the last X commits and merge them into 1
    • http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html