how to re-order commits in Git non-interactively
问题 What non-interactive git command(s) achieve the change from Before to After? Before: A---B---C---D After: A---C'---B'---D' 回答1: In your case, you can rebase interactive: git rebase -i HEAD~4 Then you can just reorder your picks For example lets add three more files to our branch: git add A git commit -m "A" git add B git commit -m "B" git add C git commit -m "C" Your shortlog will be: $ git shortlog (3): A B C If you want to reorder B with C: $ git rebase -i HEAD~2 pick 1f9133d B pick 33f41be