2009-12-02 27 views
16

如果我有两个不同的ProjectNamesGitHub git remote add origin [email protected]:username/ProjectName一次性过程?

我的机器 两个混帐项目

我可以用这个代码在两个目录这样

/foo1$ git remote add origin [email protected]:username/ProjectName-1 
/foo2$ git remote add origin [email protected]:username/ProjectName-2 

管理这是它获得存储在目录中,或混帐系统中的配置文件?

+0

这是一个错误,你把“起源”两次?每个远程的远程名称必须不同。否则,第二个命令会覆盖第一个命令。 – 2009-12-02 14:46:46

+2

@Randal这些命令在2个不同的目录('foo1'和'foo2') – MBO 2009-12-02 14:52:54

回答

20

信息存储在.git/config文件中的每个存储库(项目)中。

是的您正在通过分别为每个存储库添加远程设备来做正确的事情。

+0

谢谢jamuraa – 2009-12-02 14:39:57

7

当然可以。当您创建GitHub上的新资料库,能够显示帮助屏幕如何检出新项目或如何GitHub上添加远程:

cd existing_git_repo 
git remote add origin [email protected]:username/test.git 
git push origin master 

遥控器只能存储在本地,你可以随时更改。

+0

谢谢MBO .... – 2009-12-02 14:40:50

2
git remote add remote_name remote_location

remote_name通常来自大多数例子。如果您有多个遥控器,那么您将使用不同的名称。对于github,我通常使用“github”而不是原点,并在其周围建立命令别名以使生活更轻松(即 - git config --global alias.pg=push github master)。还有一个github ruby​​ gem,提供了使用github的捷径。

remote_location是远程回购的url或scp路径。使用ssh进行回购,包括私人github回购使用形式为[email protected]:path/to/repo.git的scp路径。 Github将此摘要提取至[email protected]:username/repo.git。只读回购使用http和简单的URL到git回购http://host/path/to/repo.git