menu
書いてる野郎
orebike@gmail.com
GitHub とか Bitbucket とかのサービスを使う
本家の中央を適当に作る。これが本線。
適当にfork。これがリモートの自分のリポジトリになる。
$ git clone git@bitbucket.org:hogehoge/piyopiyo.git
この時点ではローカル作業用リポジトリのデフォルトの master ブランチと リモートの自分の master ブランチが繋がっている状態になっている。
もし、この時点で別ブランチがあるのなら
$ git checkout -b hoge origin/hoge $ git checkout -b piyo origin/piyo
とかやって、それぞれ接続する。
$ git checkout -b hoge_spike
$ git add hogehoge.txt $ git commit -m "hogehogehoge"
バックアップ的な意味で
$ git push origin hoge_spike
中央をupstream として登録
$ git remote add upstream git@bitbucket.org:hogehoge/fugafuga.git
masterに引き込む。masterは作業には使ってないので何の問題もなく取り込まれる
$ git checkout master $ git pull upstream master
作業ブランチを付け替えて追従する
$ git checkout hoge_spike $ git rebase master
fork の master を反映
$ git checkout master $ git push origin master
fork の作業ブランチに反映
$ git checkout hoge_spike $ git push -f origin hoge_spike
リビジョンを積み重ねたわけでなく、ブランチの親が変わっているので通常はpushできない。 なので f オプションで強制変更する。
fork して作業しているので自分以外の人間が修正していないのでこのようなことが許される
↑の作業をいくつか繰り返す
作る前に本家を取り込んで限りなくプルリクが本家状態を考慮したものにしたい
$ git checkout hoge_spike $ git checkout -b hoge $ git rebase -i master
つまり作業ブランチのコピーを作る。作って rebase を噛ますことでリビジョンの整理を行う
$ git checkout hoge $ git push origin hoge
出す
本家にマージされたらそれを取り込んで追従
$ git checkout master $ git pull upstream master
ローカル
$ git branch -D hoge_spike
fork
$ git push origin :hoge_spike
何故かコロン付きのプランチ名をpushすると消える
中央のブランチ情報をローカルに引き込む
$ git fetch upstream
トラッキングのブランチをローカルブランチを作成して繋げる
$ git checkout -b hogehoge123 upstream/hogehoge123
フォークにも反映させる
$ git push origin hogehoge123