git pull现在跟踪分支 [英] git pull currently tracked branch

查看:144
本文介绍了git pull现在跟踪分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 git checkout -b somebranch origin / somebranch 来确保我的本地分支已经跟踪了远程。无论我使用哪个分支,我都想要一种方式从追踪的分支中提取。换句话说,我想说 git pull 或其他一些命令,而不指定分支,并且它的意思是 git pull origin somebranch 如果我在本地分行 somebranch

I use git checkout -b somebranch origin/somebranch to make sure my local branches track remotes already. I would like a way to pull from the tracked branch no matter which branch I am using. In other words, I want to say git pull or some other command, without specifying the branch, and have it mean git pull origin somebranch if I'm on the local branch somebranch

有没有办法做到这一点,每个分支的配置文件中的条目?如果我们必须记住为每个分支手动输入一些配置的东西,这将很难保持。

Is there a way to do this without putting an entry in the config file for each branch? It would be difficult to maintain if we have to remember to manually enter some config stuff for each branch.

推荐答案

我不确定这是否可能,除非您首先跟踪了来自原始回购的分支(参见SO问题 a href =https://stackoverflow.com/questions/379081/track-all-remote-git-branches-as-local-branches>追踪所有远程git分支为本地分支)

I am not sure this is possible unless you have first tracked oll the branches from origin repo (see the SO question "Track all remote git branches as local branches")

另一种解决方案是(未测试)为以下项目创建别名:

The other solution would be (not tested) to make a alias for:

$ git pull refs/heads/*:refs/remotes/origin/*

From git pull 手册页
$ b

From git pull man page:


以上指定所有远程分支都使用跟踪分支在refs / remotes / origin / hierarchy下进行跟踪同名。

The above specifies that all remote branches are tracked using tracking branches in refs/remotes/origin/ hierarchy under the same name.

这篇关于git pull现在跟踪分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆