git - 如何让 git 按名称自动匹配远程分支?
问题描述
我经常使用克隆的存储库,具有“来源”(我的)和“上游”(原始来源)。我总是从 github 克隆“原始”存储库以进行处理并创建 PR,并且不时需要从“上游”拉取以与那里正在进行的最新更改同步。
在git clone <origin uri>
我能做到之后
git push/pull
没有指定分支,因为它已经被跟踪;但是在另一个遥控器上这样做
git pull upstream
当例如在master
分支上时,我希望 git 实际执行
git pull upstream master
代替:
You asked to pull from the remote 'upstream', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
我知道我可以配置跟踪远程,但我想知道这是否可以是自动的,只要分支名称相同。
解决方案
您可以使用以下配置,因此每当您从远程签出新分支时,它将被自动跟踪,而无需您使用--set-upstream-to
或设置跟踪--track
git config --global branch.autosetupmerge true
推荐阅读
- c++ - 在 C++ 中使用 MATLAB API,matOpen 不起作用
- java - 在现有代码中计算数组(java)中的重复字符串
- ios - Xcode 应用程序包 ID 与代码签名 ID 不匹配
- django - 为什么我的模板没有从一个函数中获取视图数据?
- python - 熊猫:将数据框中的多列加到一个新列中
- pyspark - Pyspark 根据距离连接两个表
- ubuntu - 在 docker 中执行 apt-get update 时出现“解决‘archive.ubuntu.com’的临时故障”错误
- c - DbgView 如何捕获 DbgPrintEx 函数发送的内核调试消息?
- ruby - 将创建的测试文件放在哪里。Ruby 目录结构
- c# - 如何在 Unity、Unreal 等游戏引擎中或直接在 webXr 中实时导出从 Grasshopper、Rhino3d 分析的顶点颜色?