GitHub git remote add origin git@github.com:username/ProjectName a one time process?

StackOverflow https://stackoverflow.com/questions/1833258

  •  11-09-2019
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top