Home  >  Article  >  Development Tools  >  How to change comments in git

How to change comments in git

WBOY
WBOYOriginal
2022-01-07 11:46:589301browse

How to modify comments in git: 1. Use the "git commit --amend -m" command to modify the comment content before pushing; 2. Use the "git push -f" command to modify the comment content before push Then modify the comment content.

How to change comments in git

The operating environment of this article: Windows 10 system, Git version 2.30.0, Dell G3 computer.

How to change comments in git

1. If you haven’t pushed yet, you need to modify the comments

First check your submission How many times, then execute

git rebase -i HEAD~number (how many commits do you want to modify)

Next execute, modify the comment

git commit --amend

Modify After finishing the comment, save it, execute

git rebase --continue

and finally push it. After executing

git push origin 当前分支名

2.push, modify the comment

. You can execute the above command first, and then execute it violently. The following command:

The operation is the same as above, but in the end you need to force push (the reason for doing this is to overwrite the push of the remote branch)

git push origin 当前分支名 -f

Recommended learning: " Git tutorial

The above is the detailed content of How to change comments in git. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn