Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Sharing my git cheat sheet (martinadams.tumblr.com)
7 points by martin-adams on Dec 4, 2012 | hide | past | favorite | 4 comments


For the "create a local branch from a remote branch", a more sensible option is probably:

  git checkout -t origin/branch-name
Other things that are useful:

Push and track a branch at the same time:

  git push -u origin foo
Merge a branch and always generate a merge commit, even if a fast-forward was possible:

  git merge --no-ff foo
A condensed and useful status output:

  git status -sb
Useful `git log` options:

  --abbrev-commit
(Shows as short a commitish as possible)

  --color-words
(Show word-level diffs in the same line, rather than as two whole -/+ lines)

  --decorate
(Where a commit is also a ref (e.g. the latest commit on a branch), display that ref in the output)


Awesome, thanks for the tips. I'll be sure to update the cheat sheet with the wealth of community knowledge!


Some common Git aliases would probably be a good addition, e.g., "git cm" for "git commit -m", or "git lol" for "log --graph --decorate --pretty=oneline --abbrev-commit".


Well what can I say, I hadn't come across git aliases before and looks to be very handy.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: