English 中文(简体)
GitHub git remote add origin git@github.com:username/ProjectName a one time process?
原标题:
  • 时间:2009-12-02 14:31:50
  •  标签:
  • git
  • github

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

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

/foo1$ git remote add origin git@github.com:username/ProjectName-1
/foo2$ git remote add origin git@github.com:username/ProjectName-2

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

最佳回答

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

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

问题回答

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:

cd existing_git_repo
git remote add origin git@github.com:username/test.git
git push origin master

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

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_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.





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签