[英]git branch names local vs remote tracking
I use git 1.8.3.2.我使用 git 1.8.3.2。
I use a bare "w1.git" repository to test git related things.我使用一个裸的“w1.git”存储库来测试与 git 相关的东西。
I did the following我做了以下
git clone -- file:///home/rohloff/git/w1.git w1_clone
So now I have got the following branches (leaving out SHA1 and commit messages):所以现在我有以下分支(不包括 SHA1 和提交消息):
git branch -avv
master [origin/master]
remotes/origin/HEAD -> origin/master
remotes/origin/master
So now I did所以现在我做到了
git branch origin/master
and to my complete surprise that works ?!令我惊讶的是它有效吗?!
I now have got我现在有
git branch -avv
master [remotes/origin/master]
origin/master
remotes/origin/HEAD -> origin/master
remotes/origin/master
Note how "master" now cleverly points to "remotes/origin/master".请注意“master”现在如何巧妙地指向“remotes/origin/master”。
But if I try to now create a topic branch with但是如果我现在尝试创建一个主题分支
git branch topic origin/master
I get (not surprisingly)我得到(毫不奇怪)
Warning: refname 'origin/master' is ambiguous.
So I am wondering:所以我想知道:
EDIT : It turns out the following is also allowed:编辑:事实证明以下也是允许的:
git branch origin/master
git branch remotes/origin/master
git branch refs/remotes/origin/master
After these three commands it seems there is no way at all anymore to refer to "master" from the "origin" remote repository...在这三个命令之后,似乎再也没有办法从“原始”远程存储库中引用“master”了……
EDIT : It turns out this problem is right now (15 Feb 2014) discussed on the git developer mailing list.编辑:事实证明这个问题现在(2014 年 2 月 15 日)在 git 开发人员邮件列表上讨论过。 see
看
https://marc.info/?t=139237924400005&r=1&w=2 https://marc.info/?t=139237924400005&r=1&w=2
The proposal is to forbid something like this as long as someone does not use "-f".建议是禁止这样的事情,只要有人不使用“-f”。
git branch
, if you create a local branch origin/foo when there's no remotes/origin/foo that's something that might change over time.git branch
有这样的选项,如果您在没有 remotes/origin/foo 的情况下创建本地分支 origin/foo ,这可能会随着时间的推移而改变。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.