无需重复输入分支名,Git分支远程跟踪的快捷设置方法
本地分支未跟踪远程同名分支的简化关联命令
当执行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=<remote>/<branch> main
存在更简短的命令,无需手动输入当前分支名即可关联远程同名分支:
使用
git branch -u origin/main
这是git branch --set-upstream-to的简写形式,Git会自动识别当前所在的本地分支,并将其与指定的远程分支origin/main建立跟踪关系。若需要同时完成拉取和关联,可执行
git pull origin main --set-upstream
该命令在拉取远程origin/main分支内容的同时,自动将当前本地分支设置为跟踪该远程分支,一步完成两个操作。
内容的提问来源于stack exchange,提问作者joachim
相关产品推荐
相关产品推荐

