Skip to content

Instantly share code, notes, and snippets.

@imcotton
Last active December 15, 2015 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imcotton/5276331 to your computer and use it in GitHub Desktop.
Save imcotton/5276331 to your computer and use it in GitHub Desktop.
git commits reorder by rebase
$ git init
$ touch {a,b,c,d}
$ git status -s | awk '{print "git add",$2,";git commit -qm",toupper($2)}' | sh
$ git log --one-line
xxxxxxx D
xxxxxxx C
xxxxxxx B
xxxxxxx A
$ git rebase -i HEAD^^^
# exchange line 1 to line 3
# e.g. in vi mode [ddjp :x]
$ git log --one-line
xxxxxxx B
xxxxxxx D
xxxxxxx C
xxxxxxx A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment