I have done my code development in my local branch and added commit comments as shown ( temporary, temp2) thinking that I can rebase and amend the commit message before pushing to remote repository. But after these two commits I pulled from a remote repository and merged with my local branch . But after that I am unable to rebase a specific commit before the merge so that I can edit the commit message. I am using sourcetree as client for GIT. Is there any way to edit those commit message before I push?
Asked
Active
Viewed 104 times
0
-
2I avoid all those fancy GUIs myself: they fill a much-needed gap. (I need my gap!) From the command line, you can often just run `git rebase -i` for cases like this. I can't see enough of the graph in your clip to tell whether you might need a more complex command-line command, but in any case that won't help you in the GUI.... – torek Apr 27 '16 at 09:09
-
You could modify the comments for the latest commit using `git commit --amend`. It just accepts the tip of the current branch which in your case is 'merge related'. Alternately, You could reset the latest merge, rebase your commits on top of the original remote branch – Balaji Katika Apr 27 '16 at 09:57
-
@torek I tried that but it is saying that it is not able to apply the rebase to specific commit (which is remote branch(this branch which I merged)) – kernel Apr 27 '16 at 11:36
2 Answers
1
If you do an interactive rebase, you can reword the commit messages. There might be a way to do it with your gui, else you can use the command line:
$ git rebase -i origin/master
will display a list of your commits in a code editor
Replace 'pick' by 'reword' to edit the message. You could also 'squash' the 2nd commit into the first one,

user2707671
- 1,694
- 13
- 12
-
I tried that but it is saying that it is not able to apply the rebase to specific commit which is remote branch(this branch which I merged). – kernel Apr 27 '16 at 11:35
1
One solution would be rewinding back commits, editing in a way you want and cherry-picking the upstream ones:
Checkout
temporary
commitgit reset --hard d19d86b
Edit commit message
git commit --amend
Cherry-pick
temp
commit and amend:git cherry-pick 68a0bcd git commit --amend
Merge with
master_integration
:git merge master_integration
If you need
dev_ProgramView
commit -- add it as well:git cherry-pick dev_ProgramView
All commit hashes and branch names come from your picture.

manzur
- 682
- 3
- 7
-
This is pretty much the right way to do it, with one caveat. As a safety net, I would assign a *new* branch or tag name to commit `adb321a` which is currently pointed-to by branch name `dev_ProgramView`. I cannot tell from the images which branch is (or rather, was) actually current (before the `rebase -i` started). Note to the OP: be sure to use `git rebase --abort` to cancel out the in-progress, failing rebase before doing any of the above. – torek Apr 27 '16 at 18:40
-
@torek thanks for adding that! Another way would be relying on `git reflog` when you get lost in the mass of the commits. – manzur Apr 27 '16 at 19:00