Home > Development Tools > git > body text

How to change comments in git

WBOY
Release: 2022-01-07 11:46:58
Original
9334 people have browsed it

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
Copy after login

Modify After finishing the comment, save it, execute

git rebase --continue
Copy after login

and finally push it. After executing

git push origin 当前分支名
Copy after login

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
Copy after login

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!

Related labels:
git
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template