ythy / blog

Give everything a shot
6 stars 0 forks source link

git 作者修改 #528

Open ythy opened 10 months ago

ythy commented 10 months ago

关于commit id

概述

GitHub uses your commit email address to associate commits with your account on GitHub.com. You can choose the email address that will be associated with the commits you push from the command line as well as web-based Git operations you make.

Setting your email address for every repository on your computer

  1. Open Git Bash.
  2. Set an email address in Git. You can use your GitHub-provided noreply email address or any email address.
    git config --global user.email "YOUR_EMAIL"
  3. Confirm that you have set the email address correctly in Git:
    $ git config --global user.email
    email@example.com
  4. Add the email address to your account on GitHub, so that your commits are attributed to you and appear in your contributions graph.

Setting your email address for a single repository

  1. Open Git Bash.
  2. Change the current working directory to the local repository where you want to configure the email address that you associate with your Git commits.
  3. Set an email address in Git. You can use your GitHub-provided noreply email address or any email address.
    git config user.email "YOUR_EMAIL"
  4. Confirm that you have set the email address correctly in Git:
    $ git config user.email
    email@example.com
  5. Add the email address to your account on GitHub, so that your commits are attributed to you and appear in your contributions graph.

查看

$ git log

commit 275f3e1dc6c874fd832ca3805168bb3a8be0a9fa
Author: xxxx <xxxx@xxxx.com>
Date:   Tue Nov 21 15:30:13 2023 +0800

提交时变更

git commit -a -m "msg" --author="xxx<xxx@xxx.com>"
[main 983a7406] msg
 1 file changed, 1 insertion(+), 1 deletion(-)
ythy commented 8 months ago

补充: 修改已提交的历史记录

  1. 先设置好项目别的正确name 和 email
  2. -r commit id
    git rebase -r  354eb0414b984bd2cd6317ea8cb61562d8c9dddb --exec 'git commit --amend --no-edit --reset-author'