博文

目前显示的是 三月, 2014的博文

Git rewriting local history - update previous (but not the last) commit

Suppose you haven't done any merge or push, and there is no change in the stage. Now you realize you want to make some change in one of your previous commit you haven't pushed yet. 1. Start interactive rebase process with the last 3 commit, suppose the oldest 3th commit is the one you want to update. git rebase -i HEAD~3 2. Edit the rebase command in the poped editor. From: pick f7f3f6d changed my name a bit pick 310154e updated README formatting and added blame pick a5f4a0d added cat-file # Rebase 710f0f8..a5f4a0d onto 710f0f8 # # Commands: #  p, pick = use commit #  e, edit = use commit, but stop for amending #  s, squash = use commit, but meld into previous commit # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. # To: edit f7f3f6d changed my name a bit pick 310154e updated README formatting and added blame pick a5f4a0d added cat-file # Rebase 710f0f8..a5f4a0d onto 71...