Git: edit previous commits' messages only












11














For lazy reasons I pushed a bunch of commits with default messages and now it has become cumbersome, as I don't really know what I've changed in each commit.



How do I edit just the messages of previous commits and (if possible) keep the commit tree?










share|improve this question




















  • 10




    Beware of changing public history!
    – D. Ben Knoble
    Dec 4 '18 at 20:07






  • 2




    i fear the answers here aren't giving you nearly dire enough warnings. this will create a huge mess if anyone else has pulled your history in the meantime — all the moreso if they've committed new work on top of it!
    – Eevee
    Dec 5 '18 at 6:15










  • I'll use it with cause, I have simpler case here, I'm the only that use this repo.
    – Tuyen Pham
    Dec 5 '18 at 6:20






  • 3




    Info: This is already asked (possibly many times) on Stack Overflow.
    – user202729
    Dec 5 '18 at 10:05
















11














For lazy reasons I pushed a bunch of commits with default messages and now it has become cumbersome, as I don't really know what I've changed in each commit.



How do I edit just the messages of previous commits and (if possible) keep the commit tree?










share|improve this question




















  • 10




    Beware of changing public history!
    – D. Ben Knoble
    Dec 4 '18 at 20:07






  • 2




    i fear the answers here aren't giving you nearly dire enough warnings. this will create a huge mess if anyone else has pulled your history in the meantime — all the moreso if they've committed new work on top of it!
    – Eevee
    Dec 5 '18 at 6:15










  • I'll use it with cause, I have simpler case here, I'm the only that use this repo.
    – Tuyen Pham
    Dec 5 '18 at 6:20






  • 3




    Info: This is already asked (possibly many times) on Stack Overflow.
    – user202729
    Dec 5 '18 at 10:05














11












11








11


1





For lazy reasons I pushed a bunch of commits with default messages and now it has become cumbersome, as I don't really know what I've changed in each commit.



How do I edit just the messages of previous commits and (if possible) keep the commit tree?










share|improve this question















For lazy reasons I pushed a bunch of commits with default messages and now it has become cumbersome, as I don't really know what I've changed in each commit.



How do I edit just the messages of previous commits and (if possible) keep the commit tree?







git






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 5 '18 at 11:48









Cyclic3

755217




755217










asked Dec 4 '18 at 15:19









Tuyen Pham

578114




578114








  • 10




    Beware of changing public history!
    – D. Ben Knoble
    Dec 4 '18 at 20:07






  • 2




    i fear the answers here aren't giving you nearly dire enough warnings. this will create a huge mess if anyone else has pulled your history in the meantime — all the moreso if they've committed new work on top of it!
    – Eevee
    Dec 5 '18 at 6:15










  • I'll use it with cause, I have simpler case here, I'm the only that use this repo.
    – Tuyen Pham
    Dec 5 '18 at 6:20






  • 3




    Info: This is already asked (possibly many times) on Stack Overflow.
    – user202729
    Dec 5 '18 at 10:05














  • 10




    Beware of changing public history!
    – D. Ben Knoble
    Dec 4 '18 at 20:07






  • 2




    i fear the answers here aren't giving you nearly dire enough warnings. this will create a huge mess if anyone else has pulled your history in the meantime — all the moreso if they've committed new work on top of it!
    – Eevee
    Dec 5 '18 at 6:15










  • I'll use it with cause, I have simpler case here, I'm the only that use this repo.
    – Tuyen Pham
    Dec 5 '18 at 6:20






  • 3




    Info: This is already asked (possibly many times) on Stack Overflow.
    – user202729
    Dec 5 '18 at 10:05








10




10




Beware of changing public history!
– D. Ben Knoble
Dec 4 '18 at 20:07




Beware of changing public history!
– D. Ben Knoble
Dec 4 '18 at 20:07




2




2




i fear the answers here aren't giving you nearly dire enough warnings. this will create a huge mess if anyone else has pulled your history in the meantime — all the moreso if they've committed new work on top of it!
– Eevee
Dec 5 '18 at 6:15




i fear the answers here aren't giving you nearly dire enough warnings. this will create a huge mess if anyone else has pulled your history in the meantime — all the moreso if they've committed new work on top of it!
– Eevee
Dec 5 '18 at 6:15












I'll use it with cause, I have simpler case here, I'm the only that use this repo.
– Tuyen Pham
Dec 5 '18 at 6:20




I'll use it with cause, I have simpler case here, I'm the only that use this repo.
– Tuyen Pham
Dec 5 '18 at 6:20




3




3




Info: This is already asked (possibly many times) on Stack Overflow.
– user202729
Dec 5 '18 at 10:05




Info: This is already asked (possibly many times) on Stack Overflow.
– user202729
Dec 5 '18 at 10:05










2 Answers
2






active

oldest

votes


















20














To edit the commit messages of a series of commits, I run



git rebase -i firstsha


where firstsha is an identifier for the parent commit of the first commit I want to edit. (You can use any valid reference here, so git rebase -i HEAD~4 will show the last four commits.)



In the editor that opens, change all the “pick” entries to “reword” on commits you wish to modify, then close the editor; you will then be asked to enter commit messages for all the commits you chose.



Note that this will change the commit tree, because the hashes of the commits will change. You will have to force-push your new tree, or push it to a new branch. It will also mess up merges, so avoid editing merge commits.



To quickly edit only the last commit, run



git commit --amend


(but beware of anything staged for commit though).






share|improve this answer





















  • How would it affect commit tree, will it create an intermediate vertical line in commit tree? I had only one vertical line commit tree now, and over 100 messages need to be changed.
    – Tuyen Pham
    Dec 4 '18 at 15:54








  • 3




    It won’t create a new “line” in your commit tree, it will change all the commits. If your history is currently linear, it will remain linear.
    – Stephen Kitt
    Dec 4 '18 at 15:55










  • It depends. Are you using it by yourself and not pushing to a server? Then no, only one "line". But otherwise there might be two, and based on your answers to the first two we can help you get rid of the old "line".
    – Captain Man
    Dec 4 '18 at 19:50






  • 1




    Rebase does have a flag to handle merges (I think it’s preserve-merges)
    – D. Ben Knoble
    Dec 4 '18 at 20:07



















6














What you are looking for is git rebase.



If you only wish to change the previous git commit message then you only need to use the following:



git commit --amend


And make the changes you desire to the previous commit and then save the edits.



However if you need to change older commits you need to use rebase.



git rebase -i HEAD~N 


where N equals the number of commits you wish to go back to, e.g 2 or 12 or 6, etc. etc.



Here you should get a text editor with your commits. Change the option from pick to reword to change the message.



Once you have identified all the commits you wish to change and have appropriately changed their options, save and close the editor. Then make the changes to each commit message. Once you are satisfied you can run:



git push --force


And you should have maintained your git history albeit with different hash values because you have made the necessary changes you wish. Here are some additional links you should check out:



7.6 Git Tools - Rewriting History
GitHub Help - Changing a Commit Message
StackOverflow - Question on Changing old commit messages






share|improve this answer























  • If you “reword”, you don’t need to “commit --amend”, unless you mess up the committing process somehow.
    – Stephen Kitt
    Dec 4 '18 at 15:56










  • Thanks, here the steps that I'll do as my understanding from your post: 1. do git rebase -i firstsha that firstsha is parent commit's hash of the commit that I'd want to change the message, then in editor, change pick to reword, enter new message, then issue git rebase --continue and do git push --force?
    – Tuyen Pham
    Dec 4 '18 at 15:57












  • @StephenKitt, I just noticed your answer, I was making mine as you submitted yours. I will follow your advice and look to make those edits. If it is more appropriate I can merge my answer into yours by adding the links to yours if you feel that would better suit this question than having multiple similar answers.
    – kemotep
    Dec 4 '18 at 16:03










  • @TuyenPham you only need to do git rebase -i HEAD~N with N being the number of commits back you wish to go. Change every commit option that you want to edit the message of from pick to reword, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only need git push --force [Name of git branch you are were working on]. You can always go back and do this again or do it in stages.
    – kemotep
    Dec 4 '18 at 16:17











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485918%2fgit-edit-previous-commits-messages-only%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









20














To edit the commit messages of a series of commits, I run



git rebase -i firstsha


where firstsha is an identifier for the parent commit of the first commit I want to edit. (You can use any valid reference here, so git rebase -i HEAD~4 will show the last four commits.)



In the editor that opens, change all the “pick” entries to “reword” on commits you wish to modify, then close the editor; you will then be asked to enter commit messages for all the commits you chose.



Note that this will change the commit tree, because the hashes of the commits will change. You will have to force-push your new tree, or push it to a new branch. It will also mess up merges, so avoid editing merge commits.



To quickly edit only the last commit, run



git commit --amend


(but beware of anything staged for commit though).






share|improve this answer





















  • How would it affect commit tree, will it create an intermediate vertical line in commit tree? I had only one vertical line commit tree now, and over 100 messages need to be changed.
    – Tuyen Pham
    Dec 4 '18 at 15:54








  • 3




    It won’t create a new “line” in your commit tree, it will change all the commits. If your history is currently linear, it will remain linear.
    – Stephen Kitt
    Dec 4 '18 at 15:55










  • It depends. Are you using it by yourself and not pushing to a server? Then no, only one "line". But otherwise there might be two, and based on your answers to the first two we can help you get rid of the old "line".
    – Captain Man
    Dec 4 '18 at 19:50






  • 1




    Rebase does have a flag to handle merges (I think it’s preserve-merges)
    – D. Ben Knoble
    Dec 4 '18 at 20:07
















20














To edit the commit messages of a series of commits, I run



git rebase -i firstsha


where firstsha is an identifier for the parent commit of the first commit I want to edit. (You can use any valid reference here, so git rebase -i HEAD~4 will show the last four commits.)



In the editor that opens, change all the “pick” entries to “reword” on commits you wish to modify, then close the editor; you will then be asked to enter commit messages for all the commits you chose.



Note that this will change the commit tree, because the hashes of the commits will change. You will have to force-push your new tree, or push it to a new branch. It will also mess up merges, so avoid editing merge commits.



To quickly edit only the last commit, run



git commit --amend


(but beware of anything staged for commit though).






share|improve this answer





















  • How would it affect commit tree, will it create an intermediate vertical line in commit tree? I had only one vertical line commit tree now, and over 100 messages need to be changed.
    – Tuyen Pham
    Dec 4 '18 at 15:54








  • 3




    It won’t create a new “line” in your commit tree, it will change all the commits. If your history is currently linear, it will remain linear.
    – Stephen Kitt
    Dec 4 '18 at 15:55










  • It depends. Are you using it by yourself and not pushing to a server? Then no, only one "line". But otherwise there might be two, and based on your answers to the first two we can help you get rid of the old "line".
    – Captain Man
    Dec 4 '18 at 19:50






  • 1




    Rebase does have a flag to handle merges (I think it’s preserve-merges)
    – D. Ben Knoble
    Dec 4 '18 at 20:07














20












20








20






To edit the commit messages of a series of commits, I run



git rebase -i firstsha


where firstsha is an identifier for the parent commit of the first commit I want to edit. (You can use any valid reference here, so git rebase -i HEAD~4 will show the last four commits.)



In the editor that opens, change all the “pick” entries to “reword” on commits you wish to modify, then close the editor; you will then be asked to enter commit messages for all the commits you chose.



Note that this will change the commit tree, because the hashes of the commits will change. You will have to force-push your new tree, or push it to a new branch. It will also mess up merges, so avoid editing merge commits.



To quickly edit only the last commit, run



git commit --amend


(but beware of anything staged for commit though).






share|improve this answer












To edit the commit messages of a series of commits, I run



git rebase -i firstsha


where firstsha is an identifier for the parent commit of the first commit I want to edit. (You can use any valid reference here, so git rebase -i HEAD~4 will show the last four commits.)



In the editor that opens, change all the “pick” entries to “reword” on commits you wish to modify, then close the editor; you will then be asked to enter commit messages for all the commits you chose.



Note that this will change the commit tree, because the hashes of the commits will change. You will have to force-push your new tree, or push it to a new branch. It will also mess up merges, so avoid editing merge commits.



To quickly edit only the last commit, run



git commit --amend


(but beware of anything staged for commit though).







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 4 '18 at 15:32









Stephen Kitt

165k24366445




165k24366445












  • How would it affect commit tree, will it create an intermediate vertical line in commit tree? I had only one vertical line commit tree now, and over 100 messages need to be changed.
    – Tuyen Pham
    Dec 4 '18 at 15:54








  • 3




    It won’t create a new “line” in your commit tree, it will change all the commits. If your history is currently linear, it will remain linear.
    – Stephen Kitt
    Dec 4 '18 at 15:55










  • It depends. Are you using it by yourself and not pushing to a server? Then no, only one "line". But otherwise there might be two, and based on your answers to the first two we can help you get rid of the old "line".
    – Captain Man
    Dec 4 '18 at 19:50






  • 1




    Rebase does have a flag to handle merges (I think it’s preserve-merges)
    – D. Ben Knoble
    Dec 4 '18 at 20:07


















  • How would it affect commit tree, will it create an intermediate vertical line in commit tree? I had only one vertical line commit tree now, and over 100 messages need to be changed.
    – Tuyen Pham
    Dec 4 '18 at 15:54








  • 3




    It won’t create a new “line” in your commit tree, it will change all the commits. If your history is currently linear, it will remain linear.
    – Stephen Kitt
    Dec 4 '18 at 15:55










  • It depends. Are you using it by yourself and not pushing to a server? Then no, only one "line". But otherwise there might be two, and based on your answers to the first two we can help you get rid of the old "line".
    – Captain Man
    Dec 4 '18 at 19:50






  • 1




    Rebase does have a flag to handle merges (I think it’s preserve-merges)
    – D. Ben Knoble
    Dec 4 '18 at 20:07
















How would it affect commit tree, will it create an intermediate vertical line in commit tree? I had only one vertical line commit tree now, and over 100 messages need to be changed.
– Tuyen Pham
Dec 4 '18 at 15:54






How would it affect commit tree, will it create an intermediate vertical line in commit tree? I had only one vertical line commit tree now, and over 100 messages need to be changed.
– Tuyen Pham
Dec 4 '18 at 15:54






3




3




It won’t create a new “line” in your commit tree, it will change all the commits. If your history is currently linear, it will remain linear.
– Stephen Kitt
Dec 4 '18 at 15:55




It won’t create a new “line” in your commit tree, it will change all the commits. If your history is currently linear, it will remain linear.
– Stephen Kitt
Dec 4 '18 at 15:55












It depends. Are you using it by yourself and not pushing to a server? Then no, only one "line". But otherwise there might be two, and based on your answers to the first two we can help you get rid of the old "line".
– Captain Man
Dec 4 '18 at 19:50




It depends. Are you using it by yourself and not pushing to a server? Then no, only one "line". But otherwise there might be two, and based on your answers to the first two we can help you get rid of the old "line".
– Captain Man
Dec 4 '18 at 19:50




1




1




Rebase does have a flag to handle merges (I think it’s preserve-merges)
– D. Ben Knoble
Dec 4 '18 at 20:07




Rebase does have a flag to handle merges (I think it’s preserve-merges)
– D. Ben Knoble
Dec 4 '18 at 20:07













6














What you are looking for is git rebase.



If you only wish to change the previous git commit message then you only need to use the following:



git commit --amend


And make the changes you desire to the previous commit and then save the edits.



However if you need to change older commits you need to use rebase.



git rebase -i HEAD~N 


where N equals the number of commits you wish to go back to, e.g 2 or 12 or 6, etc. etc.



Here you should get a text editor with your commits. Change the option from pick to reword to change the message.



Once you have identified all the commits you wish to change and have appropriately changed their options, save and close the editor. Then make the changes to each commit message. Once you are satisfied you can run:



git push --force


And you should have maintained your git history albeit with different hash values because you have made the necessary changes you wish. Here are some additional links you should check out:



7.6 Git Tools - Rewriting History
GitHub Help - Changing a Commit Message
StackOverflow - Question on Changing old commit messages






share|improve this answer























  • If you “reword”, you don’t need to “commit --amend”, unless you mess up the committing process somehow.
    – Stephen Kitt
    Dec 4 '18 at 15:56










  • Thanks, here the steps that I'll do as my understanding from your post: 1. do git rebase -i firstsha that firstsha is parent commit's hash of the commit that I'd want to change the message, then in editor, change pick to reword, enter new message, then issue git rebase --continue and do git push --force?
    – Tuyen Pham
    Dec 4 '18 at 15:57












  • @StephenKitt, I just noticed your answer, I was making mine as you submitted yours. I will follow your advice and look to make those edits. If it is more appropriate I can merge my answer into yours by adding the links to yours if you feel that would better suit this question than having multiple similar answers.
    – kemotep
    Dec 4 '18 at 16:03










  • @TuyenPham you only need to do git rebase -i HEAD~N with N being the number of commits back you wish to go. Change every commit option that you want to edit the message of from pick to reword, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only need git push --force [Name of git branch you are were working on]. You can always go back and do this again or do it in stages.
    – kemotep
    Dec 4 '18 at 16:17
















6














What you are looking for is git rebase.



If you only wish to change the previous git commit message then you only need to use the following:



git commit --amend


And make the changes you desire to the previous commit and then save the edits.



However if you need to change older commits you need to use rebase.



git rebase -i HEAD~N 


where N equals the number of commits you wish to go back to, e.g 2 or 12 or 6, etc. etc.



Here you should get a text editor with your commits. Change the option from pick to reword to change the message.



Once you have identified all the commits you wish to change and have appropriately changed their options, save and close the editor. Then make the changes to each commit message. Once you are satisfied you can run:



git push --force


And you should have maintained your git history albeit with different hash values because you have made the necessary changes you wish. Here are some additional links you should check out:



7.6 Git Tools - Rewriting History
GitHub Help - Changing a Commit Message
StackOverflow - Question on Changing old commit messages






share|improve this answer























  • If you “reword”, you don’t need to “commit --amend”, unless you mess up the committing process somehow.
    – Stephen Kitt
    Dec 4 '18 at 15:56










  • Thanks, here the steps that I'll do as my understanding from your post: 1. do git rebase -i firstsha that firstsha is parent commit's hash of the commit that I'd want to change the message, then in editor, change pick to reword, enter new message, then issue git rebase --continue and do git push --force?
    – Tuyen Pham
    Dec 4 '18 at 15:57












  • @StephenKitt, I just noticed your answer, I was making mine as you submitted yours. I will follow your advice and look to make those edits. If it is more appropriate I can merge my answer into yours by adding the links to yours if you feel that would better suit this question than having multiple similar answers.
    – kemotep
    Dec 4 '18 at 16:03










  • @TuyenPham you only need to do git rebase -i HEAD~N with N being the number of commits back you wish to go. Change every commit option that you want to edit the message of from pick to reword, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only need git push --force [Name of git branch you are were working on]. You can always go back and do this again or do it in stages.
    – kemotep
    Dec 4 '18 at 16:17














6












6








6






What you are looking for is git rebase.



If you only wish to change the previous git commit message then you only need to use the following:



git commit --amend


And make the changes you desire to the previous commit and then save the edits.



However if you need to change older commits you need to use rebase.



git rebase -i HEAD~N 


where N equals the number of commits you wish to go back to, e.g 2 or 12 or 6, etc. etc.



Here you should get a text editor with your commits. Change the option from pick to reword to change the message.



Once you have identified all the commits you wish to change and have appropriately changed their options, save and close the editor. Then make the changes to each commit message. Once you are satisfied you can run:



git push --force


And you should have maintained your git history albeit with different hash values because you have made the necessary changes you wish. Here are some additional links you should check out:



7.6 Git Tools - Rewriting History
GitHub Help - Changing a Commit Message
StackOverflow - Question on Changing old commit messages






share|improve this answer














What you are looking for is git rebase.



If you only wish to change the previous git commit message then you only need to use the following:



git commit --amend


And make the changes you desire to the previous commit and then save the edits.



However if you need to change older commits you need to use rebase.



git rebase -i HEAD~N 


where N equals the number of commits you wish to go back to, e.g 2 or 12 or 6, etc. etc.



Here you should get a text editor with your commits. Change the option from pick to reword to change the message.



Once you have identified all the commits you wish to change and have appropriately changed their options, save and close the editor. Then make the changes to each commit message. Once you are satisfied you can run:



git push --force


And you should have maintained your git history albeit with different hash values because you have made the necessary changes you wish. Here are some additional links you should check out:



7.6 Git Tools - Rewriting History
GitHub Help - Changing a Commit Message
StackOverflow - Question on Changing old commit messages







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 4 '18 at 16:14

























answered Dec 4 '18 at 15:39









kemotep

2,0313620




2,0313620












  • If you “reword”, you don’t need to “commit --amend”, unless you mess up the committing process somehow.
    – Stephen Kitt
    Dec 4 '18 at 15:56










  • Thanks, here the steps that I'll do as my understanding from your post: 1. do git rebase -i firstsha that firstsha is parent commit's hash of the commit that I'd want to change the message, then in editor, change pick to reword, enter new message, then issue git rebase --continue and do git push --force?
    – Tuyen Pham
    Dec 4 '18 at 15:57












  • @StephenKitt, I just noticed your answer, I was making mine as you submitted yours. I will follow your advice and look to make those edits. If it is more appropriate I can merge my answer into yours by adding the links to yours if you feel that would better suit this question than having multiple similar answers.
    – kemotep
    Dec 4 '18 at 16:03










  • @TuyenPham you only need to do git rebase -i HEAD~N with N being the number of commits back you wish to go. Change every commit option that you want to edit the message of from pick to reword, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only need git push --force [Name of git branch you are were working on]. You can always go back and do this again or do it in stages.
    – kemotep
    Dec 4 '18 at 16:17


















  • If you “reword”, you don’t need to “commit --amend”, unless you mess up the committing process somehow.
    – Stephen Kitt
    Dec 4 '18 at 15:56










  • Thanks, here the steps that I'll do as my understanding from your post: 1. do git rebase -i firstsha that firstsha is parent commit's hash of the commit that I'd want to change the message, then in editor, change pick to reword, enter new message, then issue git rebase --continue and do git push --force?
    – Tuyen Pham
    Dec 4 '18 at 15:57












  • @StephenKitt, I just noticed your answer, I was making mine as you submitted yours. I will follow your advice and look to make those edits. If it is more appropriate I can merge my answer into yours by adding the links to yours if you feel that would better suit this question than having multiple similar answers.
    – kemotep
    Dec 4 '18 at 16:03










  • @TuyenPham you only need to do git rebase -i HEAD~N with N being the number of commits back you wish to go. Change every commit option that you want to edit the message of from pick to reword, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only need git push --force [Name of git branch you are were working on]. You can always go back and do this again or do it in stages.
    – kemotep
    Dec 4 '18 at 16:17
















If you “reword”, you don’t need to “commit --amend”, unless you mess up the committing process somehow.
– Stephen Kitt
Dec 4 '18 at 15:56




If you “reword”, you don’t need to “commit --amend”, unless you mess up the committing process somehow.
– Stephen Kitt
Dec 4 '18 at 15:56












Thanks, here the steps that I'll do as my understanding from your post: 1. do git rebase -i firstsha that firstsha is parent commit's hash of the commit that I'd want to change the message, then in editor, change pick to reword, enter new message, then issue git rebase --continue and do git push --force?
– Tuyen Pham
Dec 4 '18 at 15:57






Thanks, here the steps that I'll do as my understanding from your post: 1. do git rebase -i firstsha that firstsha is parent commit's hash of the commit that I'd want to change the message, then in editor, change pick to reword, enter new message, then issue git rebase --continue and do git push --force?
– Tuyen Pham
Dec 4 '18 at 15:57














@StephenKitt, I just noticed your answer, I was making mine as you submitted yours. I will follow your advice and look to make those edits. If it is more appropriate I can merge my answer into yours by adding the links to yours if you feel that would better suit this question than having multiple similar answers.
– kemotep
Dec 4 '18 at 16:03




@StephenKitt, I just noticed your answer, I was making mine as you submitted yours. I will follow your advice and look to make those edits. If it is more appropriate I can merge my answer into yours by adding the links to yours if you feel that would better suit this question than having multiple similar answers.
– kemotep
Dec 4 '18 at 16:03












@TuyenPham you only need to do git rebase -i HEAD~N with N being the number of commits back you wish to go. Change every commit option that you want to edit the message of from pick to reword, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only need git push --force [Name of git branch you are were working on]. You can always go back and do this again or do it in stages.
– kemotep
Dec 4 '18 at 16:17




@TuyenPham you only need to do git rebase -i HEAD~N with N being the number of commits back you wish to go. Change every commit option that you want to edit the message of from pick to reword, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only need git push --force [Name of git branch you are were working on]. You can always go back and do this again or do it in stages.
– kemotep
Dec 4 '18 at 16:17


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485918%2fgit-edit-previous-commits-messages-only%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Berounka

Sphinx de Gizeh

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...