1. Qiita
  2. 投稿
  3. Git

git pull を --set-upstream-to で引数無しで実行可能にする

  • 77
  • 0

--set-upstream-to を使う

git pull は基本は引数が必要

$ 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> branch_name

デフォルト参照先を決めるのには、各ローカルブランチごとに --set-upstream-to を使う

$ git branch --set-upstream-to=origin/master master
$ git branch --set-upstream-to=origin/develop develop
$ git branch --set-upstream-to=origin/gh-pages gh-pages

設定の一覧を見るには git branch -vv


$ git branch -vv
* develop  6834af6 [origin/develop] Commit message..
  gh-pages aec8d8f [origin/gh-pages] Commit message..
  master   ac4f990 [origin/master] Commit message..

こんな -vv ダブルピースなオプションあったんですね..

git push -u origin branch_name でお手軽登録


$ git push -u origin master