ローカル・リモートブランチとoriginのはなし

いわゆる

git push origin master

のorigin や

git branch --set-upstream-to origin/master

にでてくる origin/master 、ローカルブランチとリモートブランチなどのはなしです。

git clone してから git push するまで、どのようなことが起こっているかを整理しつつ、originとか origin/master とかってナンなのってのを整理してみます。

git clone

まず git clone したとき、ローカルのディレクトリには

01.png

この「origin」には cloneした先のリポジトリサーバのURLが自動的に設定されていまます。

$ git config --list
....
remote.origin.url=https://github.com/xxxx/hello.git

こんな感じです

ちなみに、このリモートリポジトリのサーバ名は自由に追加することができます

$ git remote
origin
$ git remote add teamone https://github.com/xxxx/hello.git   追加(ちなみに削除はremove)
$ git remote
origin
teamone
$ git config --list
remote.origin.url=https://github.com/xxxx/hello.git
remote.teamone.url=https://github.com/masatomix/helloworld1.git

リモートのリポジトリをcloneしたとき、ローカルには

https://git-scm.com/book/ja/v2/Git-%E3%81%AE%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E6%A9%9F%E8%83%BD-%E3%83%AA%E3%83%A2%E3%83%BC%E3%83%88%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS