Git Cheatsheet

All those once-a-month git commands that I can never remember.

Posted: Thu 12 Jan, 2017, 15:02

How to revert one file to HEAD

    git checkout HEAD -- <filename>

How to revert everything to HEAD

    git reset HEAD --hard

How to merge from master

Pull latest changed to your local master and then do

    git rebase master

If there are merge conflicts then fix and then do

    git rebase --continue

Remove all untracked files and directories

    git clean -fd

To set git auth to clone from behind firewall

    git config --global http.proxy 'http://user:pass@proxy_host:proxy_port'

To clone to Windows, but make it think it is UNIX (like from git bash vim)

    git config --global core.autocrlf false

And the flip it back to true to keep your Windows clones working.

Revert last x changes

    git revert --no-edit master~24..HEAD

Will revert last 24 (inclusive) changes.