Git rebase to stop, view, and edit each one when committed

I notice that when I reinstall and encounter a merge conflict, it has incremental changes for the current commit, so it's easy to find what has been done in the commit and change it, but then you can also just do a 'git rebase -continue' and it apply this change with the same commitments message as before.

Is there a way to make this happen for specific commits or all commits, so I can easily reinstall and edit the previous changes that I made to work with the changes that I reset? It seems like it would be a lot easier than just setting the editing in all commits, and then doing β€œgit reset --soft HEAD ~” so that the changes are visible, and I can verify that they make sense for the new HEAD, the editing and the need run 'git commit -m "message".

My use case is that in the repository I'm working with, its file structure was greatly reorganized, and git failed to make the appropriate changes, but says that the merge was successful.

Thanks!

+7
git
source share
3 answers

I think you're looking for an interactive reboot and rewriting of git history. This will allow you to squash as well as modify commit messages.

git rebase -i branch # <branch> should be the parent branch ie develop/master 

Rewriting git history

 # for instance >>> git rebase -i branch pick 8705209 first edit 7979797 second # Use edit wherever you want to view and edit commit squash 9793757 third # Use squash to squash commits into the previous one. 
+7
source share

Just git commit --amend before git rebase --continue .

Alternatively, use git-cherry-pick --no-commit commit1..commitN .

+3
source share

make this happen for certain commits

Run an interactive reboot with git rebase -i HEAD~~~ .

This opens the editor with a list of commits:

 pick 1234567 fix stuff pick 789abcd new features pick 0102030 break everything 

Change pick to edit to the commit (or commit) you want to edit. Save and exit the editor.

Then git will return you to these commits, one by one, and you will be able to edit them. I think what you are missing is that at the moment you can view the differences that are supplied with git diff --cached .

After editing each of them, use git rebase --continue to continue.

+1
source share

All Articles