git pullをもっと楽に
前に書いた記事ですが
かなり前に書いた記事でレイアウト崩れてたので書き直した
git pullするときに
$git pull origin master
って感じでリモートとブランチを書きますよね?
書かなければこんな感じでエラーが出ます
$git pull There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details git pull <remote> <branch> If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/<branch> hoge
これはブランチのデフォルトの参照先が設定されていないのでエラーになります
デフォルトの参照先を設定してやればgit pull
だけで、そのブランチのリモートから更新を取得できます
設定方法
設定方法は2種類あります
デフォルトリモートブランチ設定
#書式 : git branch --set-upstream-to=origin/リモートブランチ名 ローカルブランチ名 git branch --set-upstream-to=origin/rhoge lhoge #書式 : git push -u リモート名 git push -u origin rhoge
どちらもrhogeにデフォルトの参照を設定しています。
1つ目の方法はちょっと長いですが
現在のブランチとは別のブランチの設定を変更できるというメリットがあります
2つ目の方法は現在のブランチしか設定できませんがかなり楽ちんです
設定の確認方法
#デフォルト参照先の情報が表示されます $git branch -vv