If it has been submitted through git push, it depends on what git server your company uses. Generally, if users want to modify it, they need relevant permissions and contact the administrator; if other developers have modified and submitted it based on your submission, That would be even more troublesome, as all subsequent submissions would have to be done again;
If it has not been pushed to the server, but the commit has been made locally, and no new commit has been made, just git commit --amend;如果进行了新的commit,只需要git reset --soft xxx (xxx有问题那次提交的commit id),然后在进行git commit will do, but all subsequent submissions will become one submission; if you want to keep each submission independent, use
xxx still has a problem with the commit id of that submission. Create a separate tmp branch modification description, then cherry-pick the subsequent submissions one by one to the new branch, and then delete the old branch.
Although this question has been in the past for a long time, I still want to add one more:
If you want to modify the author of previous commits, here is a script you can use: link~
git commit --amend or you can use git reset HARD to cancel the last commit and then try again.
But since it has already been pushed, I don’t know how to do it. . .
Note:
I tested it and found that in the gerrit environment, just using git commit --amend to modify the commit message will fail to submit.
Change the code, such as adding a blank line, and then git add and git commit --amend to submit it.
git commit --amend
You can make changes to the last submissionpush -f
If the last submission has been pushed, you need to add the f parameter to cover the server, but this is not recommendedIf it has been submitted through
git push
, it depends on what git server your company uses. Generally, if users want to modify it, they need relevant permissions and contact the administrator; if other developers have modified and submitted it based on your submission, That would be even more troublesome, as all subsequent submissions would have to be done again;If it has not been pushed to the server, but the commit has been made locally, and no new commit has been made, just
git commit --amend
;如果进行了新的commit,只需要git reset --soft xxx
(xxx有问题那次提交的commit id),然后在进行git commit
will do, but all subsequent submissions will become one submission; if you want to keep each submission independent, usexxx still has a problem with the commit id of that submission. Create a separate tmp branch modification description, then cherry-pick the subsequent submissions one by one to the new branch, and then delete the old branch.
Although this question has been in the past for a long time, I still want to add one more:
If you want to modify the author of previous commits, here is a script you can use: link~
git commit --amend or you can use git reset HARD to cancel the last commit and then try again.
But since it has already been pushed, I don’t know how to do it. . .
git commit --amend
Do you have a code review system? Similar to Gerrit? This kind of thing can be submitted multiple times before submitting
git commit --amend
Note:
I tested it and found that in the gerrit environment, just using git commit --amend to modify the commit message will fail to submit.
Change the code, such as adding a blank line, and then git add and git commit --amend to submit it.
git commit --amend
The question is already well answered on stack overflow :)
http://stackoverflow.com/questions/179123/edit-an-incorrect-commit-message-in-git