没有原始用户信息的Git推送来自另一个仓库的提交

时间:2015-08-13 08:58:31

标签: git git-push git-pull git-remote

我正在开发一个关于客户端存储库的项目,现在我想在没有客户知道的情况下添加另一个开发人员。

我尝试设置新的存储库,将其添加为我的机器中的远程服务器然后从备用服务器(其他开发人员提交的服务器)提取推送到源(客户回购),但即使其他开发人员没有任何访问客户端repo的提交,那里显示为他的。

我应该如何避免这种情况并将他的承诺推给客户回购作为我的?

  

e.g。

     

开发人员对file1进行更改并将其提交到repo2

     

我从repo2拉出来检查代码&把它推到repo1

     

在repo2中,它显示file1已更改&提交是由开发人员

     

我需要它会显示file1已更改&承诺是由我在回购1下做出的

1 个答案:

答案 0 :(得分:2)

Git允许您指定作者:

git commit ... [--author=<author>]

让开发人员使用您的姓名,您的要求将得到满足。

示例:

$ git init
Initialized empty Git repository in c:/projects/bb/.git/

$ touch a
$ git add a
$ git commit -m "new file" --author="Author Name <email@address.com>"
[master (root-commit) cb6ca75] new file
 Author: Author Name <email@address.com>
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a

$ git log
commit cb6ca75753e13de07202f131d730c68df1a96941
Author: Author Name <email@address.com>
Date:   Thu Aug 13 12:24:21 2015 +0300

    new file

如果要确保开发人员代表Author Name <email@address.com>提交更改,您可以添加别名:

git config --local alias.com 'commit --author="Author Name <email@address.com>"'

然后使用它

$ touch file2
$ git add file2
$ git com -m "File2"
[master ed88a10] File2
 Author: Author Name <email@address.com>
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 file2

$ git log
commit ed88a10d1e1fef95cebd7d9cbc028314e6a3fa54
Author: Author Name <email@address.com>
Date:   Thu Aug 13 12:46:48 2015 +0300

    File2
commit cb6ca75753e13de07202f131d730c68df1a96941
Author: Author Name <email@address.com>
Date:   Thu Aug 13 12:24:21 2015 +0300

    new file
相关问题