Git 指定本地分支的远程追踪分支

背景

有时我们在 git pull 时,可能会遇到 “There is no tracking information for the current branch. Please specify which branch you want to merge with.” 之类的错误。此时可能需要把本地分支与它对应的远程分支建立追踪关系,这样每次 git pull 的时候就不需要显式指定远程分支了。

操作方法

git branch --set-upstream-to=origin/<remote_branch> <local_branch>
  • <local_branch> 表示本地分支。
  • <remote_branch> 表示本地分支对应的远程分支。
标签: Git
最后更新:2023-02-12 13:14:23