git - reorder commits safely

牧云@^-^@ 提交于 2019-12-08 11:21:33
Adam Dymitruk

did you make the contents of the files differ by a lot? It can be seen as a move if they are too similar. You should get stopped with a conflict when you try and apply a patch to remove a file that's not there.

Hope this helps.

You can rebase, compare the result, and then possibly reset to the old state. A simple combination of

  • git stash save --include-untracked to get into a clean state
  • git rev-parse HEAD to get the hash of the current commit
  • git rebase to do the real work
  • git checkout the_previously_saved_hash . to restore the state before rebasing
  • git clean -fd to get rid of all superfluous files
  • git commit -m "Undoing the changes introduces by rebase." which may fail if the rebase introduced no changes (this failure can be silently ignored)
  • git stash pop to re-introduce the stashed-away "pollution"

should do... I guess I'll try to make a script like this soon as it's something I need as well.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!