如何在不设置全局凭据的情况下提交共享存储库?

时间:2021-06-17 14:13:50

标签: git

我对要提交的暂存系统进行了一些更改。 这是一个共享系统,所以我不想在配置中添加我自己的用户。 当我尝试像那样提交时,显然我得到:

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.

我不想这样做。

当我尝试这个

git commit -c author.name="username" author.email="user@domain.com"

我明白

fatal: could not lookup commit author.name=username

当我尝试

git commit --author "user <user@domain.com>" -m "Some text"

我明白

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.

如何提交更改?

2 个答案:

答案 0 :(得分:1)

来自 git commit --help 的文档

<块引用>

--author=

覆盖提交作者。使用标准 A U Thor 格式指定明确的作者。否则 被假定为一个模式,用于搜索该作者的现有提交(即 rev-list --all -i --author=);然后从找到的第一个此类提交中复制提交作者。

在我自己的 repo 中尝试 git rev-list --all -i --author="" 后,我有一些提交,这意味着可能

git commit --author="" -m "fix"

应该可以工作,除非您的存储库根本没有提交

答案 1 :(得分:1)

试试这个,

git -c user.name='Chaz' -c user.email='chaz@email.org' commit -m '...'

这来自这里,但我想你们俩都在努力实现同样的目标。

参考this