Preface
If you find that there is a problem with the computer's git configuration when submitting, don't worry, teach you one trick to get the commit information.
2. Modify username and email address
// Global modificationgit config --global "silinchen"
git config --global "silinccc@"// Modify for a warehousegit config "silinchen"
git config "silinccc@"
Note: The modification here is only valid for subsequent submissions
Next, see how to modify the committed information that has been submitted
3. Modify commit information, including author and email
3.1 Modify the information of the last commit
Use amend directly to correct
3.1.1 Modify the commit comment information
git commit --amend
The interface for modifying comment information appears. Enter i to enter the modification mode. After modifying the comment, press Esc to exit the editing mode, enter :wq to save and exit.
Note: Comments are generally displayed on the first line, and the content of the first character under the window is # does not need to be modified.
3.1.2 Modify the author and email address
git commit --amend --author="{username} <{email}>"
For example: git commit --amend --author="silinchen <silinccc@>"
3.2 Modify the information of a certain commit several times
3.2.1 Use log to view submission records
git log -2
Note: -2 represents the last 2 records
Or add --oneline to view the short message (oneline: one line)
git log --oneline -2
3.2.2 rebase commit that needs to be modified
gitrebase -i HEAD~2
// orgit rebase -i {commitID}// For examplegit rebase -i d95ddfb
HEAD~2 means the last two commits
Specifying the commit ID indicates the corresponding record before commit
It should be noted here that if you need to modify a commit information, the commit ID needs to be filled in the previous commit ID
After executing the rebase command, a reabse edit window will appear, and there will be a prompt under the window to operate.
Here, the pick at the front of the commit that needs to be modified is changed to edit, which can be one or more.
According to the prompt, use --amend to modify it next
3.2.3 Modify commit information
Modify comment information only
git commit --amend
Only modify the author and email address
git commit --amend --author="{username} <{email}>" --no-edit
Modify comment information, author, and email address at the same time
git commit --amend --author="{username} <{email}>"
After the modification is completed, continue to execute the following commands
git rebase --continue
If you modify multiple items, repeat the above 3.3.2 operations.
Until the following prompt appears, all modifications have been completed.
Successfully rebased and updated refs/heads/master.
3.2.4 Push repository changes to remote repository
Force push
Note: When the repository is operated by multiple people, it may overwrite the code of others push, please operate with caution.
git push --force origin master