fetch and checkout a remote git branch in just one command

前端 未结 1 1772
天命终不由人
天命终不由人 2021-01-17 18:12

If

  • I have local repo with a remote $REMOTE already set up
  • and a new branch $BRANCH exists on the remote repo that I haven\'t
1条回答
  •  独厮守ぢ
    2021-01-17 18:24

    There is no builtin command, but you could define an alias in your ~/.gitconfig:

    [alias]
      fetch-checkout = !sh -c 'git fetch $1 $2 && git checkout $2' -
    

    0 讨论(0)
提交回复
热议问题