web-dev-qa-db-ja.com

GitHub git remote add Origin [email protected]:username / ProjectNameワンタイムプロセス?

マシン上に2つの異なるProjectNamesを持つ2つのgitプロジェクトがある場合

このような2つのディレクトリでこのコードを使用して管理できますか

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

それはディレクトリに保存されていますか、それともシステムのgit設定ファイルに保存されていますか?

16
Sumit M Asok

情報は、各リポジトリ(プロジェクト)の.git/configファイルに保存されます。

はいリモートを各リポジトリに個別に追加することで、正しいことを行っています。

20
jamuraa

できますよ。 GitHubで新しいリポジトリを作成すると、新しいプロジェクトをチェックアウトする方法やGitHubをリモートとして追加する方法のヘルプ画面が表示されます。

cd existing_git_repo
git remote add Origin [email protected]:username/test.git
git Push Origin master

リモコンはローカルにのみ保存され、いつでも変更できます。

7
MBO
git remote add remote_name remote_location

remote_nameは通常、ほとんどの例でOriginです。複数のリモコンがある場合は、別の名前を使用します。 githubの場合、私は通常Originの代わりに「github」を使用し、これを中心にコマンドエイリアスを作成して作業を楽にします(つまり、git config --global alias.pg=Push github master)。 githubを使用するためのショートカットを提供するgithub Ruby gemもあります。

remote_locationは、リモートリポジトリへのurlまたはscpパスです。プライベートgithubリポジトリを含むsshを使用するリポジトリは、user@Host:path/to/repo.gitの形式のscpパスを使用します。 Githubはこれをgit@github:username/repo.gitに抽象化します。読み取り専用リポジトリはhttpを使用し、gitリポジトリhttp://Host/path/to/repo.gitへの単純なURLです。

2
Mark Carey