撤消git rebase - Undoing a git rebase

問題:

Does anybody know how to easily undo a git rebase? 有人知道如何輕鬆撤消git rebase嗎? git

The only way that comes to mind is to go at it manually: 想到的惟一方法是手動進行操做: app

  • git checkout the commit parent to both of the branches git簽出兩個分支的提交父對象
  • then create a temp branch from there 而後從那裏建立一個臨時分支
  • cherry-pick all commits by hand 手動選擇全部提交
  • replace the branch in which I rebased by the manually-created branch 用手動建立的分支替換我從新創建基礎的分支

In my current situation this is gonna work because I can easily spot commits from both branches (one was my stuff, the other was my colleague's stuff). 在我目前的狀況下,這是可行的,由於我能夠輕鬆地發現兩個分支的提交(一個是個人東西,另外一個是我同事的東西)。 ide

However my approach strikes me as suboptimal and error-prone (let's say I had just rebased with 2 of my own branches). 可是,個人方法給個人印象是次優且容易出錯(例如,我剛剛使用本身的兩個分支進行了從新基準化)。 this

Any ideas? 有任何想法嗎? idea

Clarification: I'm talking about a rebase during which a bunch of commits were replayed. 澄清:我說的是一個重定基礎,在此基礎上重播了不少提交。 Not only one. 不僅是一個 spa


解決方案:

參考一: https://stackoom.com/question/Z5W/撤消git-rebase
參考二: https://oldbug.net/q/Z5W/Undoing-a-git-rebase
相關文章
相關標籤/搜索