GitHub git remote add origin [email protected]:username/ProjectName 一次性过程?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1833258/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 07:26:58  来源:igfitidea点击:

GitHub git remote add origin [email protected]:username/ProjectName a one time process?

gitgithub

提问by Sumit M Asok

if I have two git projects on my machine with two different ProjectNames

如果我的机器上有两个具有两个不同 ProjectNames 的 git 项目

can I manage it with this code in two directories like this

我可以在这样的两个目录中使用此代码管理它吗

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

Is it getting stored in the directory or in a git config file in system?

它是存储在目录中还是系统中的 git 配置文件中?

回答by jamuraa

The information is stored in each repository (project), in the .git/configfile.

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

Yesyou are doing the right thing by adding the remote to each repository separately.

是的,您通过将遥控器分别添加到每个存储库来做正确的事情。

回答by MBO

Sure you can. When you create new repository on GitHub it shows help screen how to checkout new project or how to add GitHub as remote:

你当然可以。当您在 GitHub 上创建新存储库时,它会显示帮助屏幕如何检出新项目或如何将 GitHub 添加为远程:

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

Remotes are stored only locally, you can always change them.

遥控器仅存储在本地,您可以随时更改它们。

回答by Mark Carey

git remote add remote_name remote_location

remote_name is usually origin in most examples. If you have more than one remote then you will use a different name. For github I usually use "github" instead of origin and have command aliases built around this to make life easier (ie- git config --global alias.pg=push github master). There is also a github ruby gem that provides shortcuts for using github.

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

remote_location is the url or scp path to the remote repo. Repos using ssh, including private github repos use scp paths in the form of user@host:path/to/repo.git. Github abstracts this out to git@github:username/repo.git. Read only repos use http and are simple urls to the git repo http://host/path/to/repo.git.

remote_location 是远程仓库的 url 或 scp 路径。使用 ssh 的存储库,包括私有 github 存储库使用 .scp 格式的 scp 路径user@host:path/to/repo.git。Github 将其抽象为git@github:username/repo.git. 只读 repos 使用 http 并且是 git repo 的简单 URL http://host/path/to/repo.git