Guides: Cool and unusual Git techniques
Please, add your favorite cool and unusual Git techniques to this guide!
git add --patch
Lets you commit specific lines rather than whole files.
git add --interactive
--interactive works very similar to --patch, but gives you much more flexibility in choosing what (untracked) files and/or hunks you want to stage.
git stash
Stash away the uncommited changes in your working directory to get a clean HEAD.
Rebasing
Rebasing is neat for cleaning up commits, but you will generally not want to rebase already pushed commits – it becomes messy for others who are working on forks of your repository. If for some reason you really do want to repush rebased commits, you will need to git push -f.
git commit --amend
Add your changes to the last commit instead of a new one.
git rebase --interactive
Rearrange, edit and squash commits.
git cherry-pick
Want to grab only one commit from someone else’s repository? First fetch their changes and then apply the individual commit with git cherry-pick 1111111 (where 1111111 is the beginning of the sha1 hash of the commit you want to apply).

