Skip to content

GIT Cheats

Andy Gill edited this page Oct 16, 2016 · 3 revisions

This brings publish uptodate with master changes.

% git checkout publish
% git rebase
% git checkout master

to remove all local changes

For a specific file use:

git checkout path/to/file/to/revert

For all unstaged files use:

git checkout -- .

Make sure to include the period at the end.

to undo a checking

Undo a commit and redo

From http://stackoverflow.com/questions/927358/how-to-undo-last-commits-in-git

$ git commit -m "Something terribly misguided"              (1)
$ git reset HEAD~                                           (2)

(1) This is what you want to undo

(2) This leaves your working tree (the state of your files on disk) unchanged but undoes the commit and leaves the changes you committed unstaged (so they'll appear as "Changes not staged for commit" in git status and you'll need to add them again before committing). If you only want to add more changes to the previous commit, or change the commit message1, you could use git reset --soft HEAD~ instead, which is like git reset HEAD~ but leaves your existing changes staged.

Clone this wiki locally