Home > front end >  git rebase -i master doesn't allow to edit first branch commit
git rebase -i master doesn't allow to edit first branch commit

Time:09-29

Consider the following scenario:

master -> (more commits) -> a commit
                                \ 
    my_branch                      commit 1 -> commit 2 -> commit 3

I want to go back to my_branch@commit 1 and edit some files, so assuming my_branch is on commit 3 I simply do git rebase -i master and mark edit commit 1. However, when git stops on that commit, it doesn't show any changes ie: git status simply returns empty none of the files that were changed/delete/modified in that commit. I suspect it has something to do with commit 1 being the first commit of the branch but I can't find an easy solution to this.

Thanks and feel free to point me to previous answers but I couldn't find any.

CodePudding user response:

Edit will stop after the commit is applied.... so if you run git status, it will tell you that there's nothing to do... but if you check the log, you will see that the commit is already in history (actually, it's HEAD).... so, now edit the files that you need, add that and run git commit --amend.... then git rebase --continue

  • Related