2017-02-20 99 views
1

我以共享帐户登录,并希望以自己的身份快速提交一些更改。hg commit -u的git相当于什么?

与Mercurial我会与-u标志

-u --user USER记录中指定的用户作为提交者

hg commit -u '[email protected]' 

我试图

git commit --author='John Doe <[email protected]>' 

做但没有帮助。

由于该帐户是共享的,这不利于 Using same git repository by multiple users

是使用git config,然后删除它,当我真正做过的唯一途径?

+1

虽然'--author' *做*工作(它设置提交的*作者*),它不会改变提交的*提交者*。要设置两者,请参阅下面的吸血鬼答案(http://stackoverflow.com/a/42350173/1256452)。请注意,Mercurial没有单独的作者和提交者,只是作者。 – torek

回答

3

随着-c可以覆盖在命令行中运行任何Git配置设置。因此,就像

git -c user.name="John Doe" -c [email protected] commit 
+0

谢谢。我怀疑是从命令行传递配置选项的一种方法。我只是看错了地方。 'man git'揭示'git help commit'没有。 –

0

正常提交,然后与作者修改:

git commit --amend --author="Author Name <[email protected]>" 
+0

但通常提交我需要配置'user.name'和'user.email'。有没有简单的方法呢? –

+0

设置一个默认的,并为非默认的。 –