Git: edit previous commits' messages only
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
add a comment |
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
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
add a comment |
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
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
git
edited Dec 5 '18 at 11:48
Cyclic3
755217
755217
asked Dec 4 '18 at 15:19
Tuyen PhamTuyen 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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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).
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’spreserve-merges
)
– D. Ben Knoble
Dec 4 '18 at 20:07
add a comment |
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
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. dogit rebase -i firstsha
thatfirstsha
is parent commit's hash of the commit that I'd want to change the message, then in editor, changepick
toreword
,enter
new message, then issuegit rebase --continue
and dogit 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 dogit 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 frompick
toreword
, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only needgit 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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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).
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’spreserve-merges
)
– D. Ben Knoble
Dec 4 '18 at 20:07
add a comment |
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).
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’spreserve-merges
)
– D. Ben Knoble
Dec 4 '18 at 20:07
add a comment |
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).
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).
answered Dec 4 '18 at 15:32
Stephen KittStephen Kitt
166k24367447
166k24367447
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’spreserve-merges
)
– D. Ben Knoble
Dec 4 '18 at 20:07
add a comment |
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’spreserve-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
add a comment |
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
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. dogit rebase -i firstsha
thatfirstsha
is parent commit's hash of the commit that I'd want to change the message, then in editor, changepick
toreword
,enter
new message, then issuegit rebase --continue
and dogit 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 dogit 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 frompick
toreword
, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only needgit 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
add a comment |
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
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. dogit rebase -i firstsha
thatfirstsha
is parent commit's hash of the commit that I'd want to change the message, then in editor, changepick
toreword
,enter
new message, then issuegit rebase --continue
and dogit 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 dogit 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 frompick
toreword
, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only needgit 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
add a comment |
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
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
edited Dec 4 '18 at 16:14
answered Dec 4 '18 at 15:39
kemotepkemotep
2,0613620
2,0613620
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. dogit rebase -i firstsha
thatfirstsha
is parent commit's hash of the commit that I'd want to change the message, then in editor, changepick
toreword
,enter
new message, then issuegit rebase --continue
and dogit 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 dogit 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 frompick
toreword
, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only needgit 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
add a comment |
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. dogit rebase -i firstsha
thatfirstsha
is parent commit's hash of the commit that I'd want to change the message, then in editor, changepick
toreword
,enter
new message, then issuegit rebase --continue
and dogit 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 dogit 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 frompick
toreword
, save this file, make the changes to each of those commit files and save those. Once you are confident you are done you only needgit 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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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