use*_*593 4 git git-filter-branch git-commit gitlab
我已经创建了 ssh 密钥并将其添加到我的 gitlab 帐户中。
然后,我做出了承诺:
git add .
git commit -m "w"
git push origin master
Run Code Online (Sandbox Code Playgroud)
但正如你所看到的,我提交时的用户名是root(这是因为我笔记本电脑上的用户是root
1)如何设置所需的用户名(让我们称之为)batman,这样我希望将batman显示为提交作者而不是root?
2)我可以只使用 gitlab 界面来完成此操作,而不弄乱笔记本电脑上的 git 配置吗?(我这样问是因为我有几个 git 帐户,并且我需要为我的项目使用不同的帐户)
如何设置所需的用户名(让我们称之为batman),这样我希望将batman 显示为提交作者而不是root?
# Set the username for git commit
git config --global user.name "<your name>"
# Set the emailfor git commit
git config --global user.email "<your email address>"
Run Code Online (Sandbox Code Playgroud)
...我需要为我的项目使用不同的帐户
# --local is the default so you don't have to add it
# Set the username for git commit
git config --local user.name="<your name>"
# Set the emailfor git commit
git config --local user.email="<your email address>"
Run Code Online (Sandbox Code Playgroud)
git filter-branch -f --env-filter '
GIT_AUTHOR_NAME="Newname"
GIT_AUTHOR_EMAIL="newemail"
GIT_COMMITTER_NAME="Newname"
GIT_COMMITTER_EMAIL="newemail"
' HEAD
Run Code Online (Sandbox Code Playgroud)
# Update the username and email as explained above
# Re-commit to update the username/email
git commit --amend --no-edit
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4130 次 |
| 最近记录: |