Skip to content
magnum edited this page Oct 16, 2020 · 8 revisions

Commit all but your latest commit (assuming upstream remote is called origin and your branch is bleeding-jumbo):

$ git push origin HEAD^:bleeding-jumbo

Obviously, using HEAD~2 instead of HEAD^ will commit all but your two latest, and so on.


To avoid local merges (see http://aaronbonner.io/post/78444674979/only-allow-git-fast-forward-merges-to-avoid-ugly and this discussion):

$ git config --global merge.ff only

You can show any commit with (most) WS changes muted, using eg.

git show -w e137572

Compare a file (in any branch) against "John Proper" (core branch)

git diff origin/core origin/bleeding-jumbo src/recovery.c

Show any file from any branch without moving away from your current tree or touching anything

git show origin/core:src/john.c

Note that the src/ is needed even if your CWD is just that.


Check out the tree from a specific date:

This syntax can't be used for anything older than 90 days.

git checkout bleeding-jumbo@{2017-11-08}

This works for any date:

git checkout $(git rev-list -1 --before="2017-11-08 23:59" bleeding-jumbo)

This variant use author-date instead of commit-date:

git checkout $(git log --reverse --author-date-order --pretty=format:'%ai %H' bleeding-jumbo | awk '{hash = $4} $1 >= "2017-11-08" {print hash; exit 0}')