Skip to content

Instantly share code, notes, and snippets.

@namikuguri
Last active December 27, 2015 01:39
Show Gist options
  • Save namikuguri/7246708 to your computer and use it in GitHub Desktop.
Save namikuguri/7246708 to your computer and use it in GitHub Desktop.
[ log-git-add-remote-repo.md ]

Git ローカルにリモートリポジトリを追加

  1. git remote add upstream [email protected]:{fork origin accout name}/{repository name}.git で fork 元のリポジトリを remote に追加する。
  2. git pull upstream master で最新リポジトリを取得する。
  3. git pull upstream master で fork 元の最新リポジトリを取得できるようになる。

リポジトリを fork した時、remote が以下のようになっている。

$ git remote -v
origin	[email protected]:{forked accout name}/{repository name}.git (fetch)
origin	[email protected]:{forked accout name}/{repository name}.git (push)

これでは git pull origin master としても fork 元の最新がとってこれないので、 git remote add upstream [email protected]:{fork origin accout name}/{repository name}.git とし、remote に fork 元のリポジトリを追加してやる。
そうしてから、remote を確認したら以下のようになる。

$ git remote -v
origin	[email protected]:{forked accout name}/{repository name}.git (fetch)
origin	[email protected]:{forked accout name}/{repository name}.git (push)
upstream	[email protected]:{fork origin accout name}/{repository name}.git (fetch)
upstream	[email protected]:{fork origin accout name}/{repository name}.git (push)

これでリポジトリの最新を取ってくるのは git pull upstream master で済む。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment