[英]How do I check if master has been merged into current branch
I was trying to find out if my branch was up to date with the remote master branch without actually running git pull
, and I read elsewhere that 我试图找出我的分支是否与远程master分支保持最新,而没有实际运行
git pull
,我在其他地方读到了
git branch -r --no-merged | grep master
should tell you. 应该告诉你。
However, if I run that, I don't get the remote master in the output (I do however get it in the output from --merged
). 但是,如果运行该命令,则不会在输出中获取远程主服务器(但是我会在
--merged
的输出中获取它)。
So I tried doing a fetch (not a pull), and running it. 因此,我尝试进行提取(而不是拉取)并运行它。 At this point, it decides that in fact, the I do need a merge,
此时,它决定实际上我确实需要合并,
git branch -r --no-merged HEAD | grep master
gives 给
remotes/origin/HEAD -> origin/master
remotes/origin/master
but interestingly, if I do -a, the local master doesn't come out in the list. 但有趣的是,如果我执行-a,则本地主机不会出现在列表中。 But it does come out in the
--merged
list. 但是它确实出现在
--merged
列表中。
I found out a way of working out if I need to do a fetch, but the way these are working is confusing me somewhat. 我发现了一种解决方法,是否需要进行提取,但是这些方法的工作方式使我有些困惑。 and I'd like to know what I'm missing.
而且我想知道我在想什么。
Is git branch -r
not actually going to the remote repository? git branch -r
实际上没有进入远程存储库吗? Or am I missing something to make it do so? 还是我想做些什么? Or is the sequence above what I actually need to do?
还是上述顺序实际上是我真正需要做的?
All (normal) git commands except fetch
and pull
will only look at the local state. 除
fetch
和pull
fetch
之外的所有(正常)git命令将仅查看本地状态。 So they will only tell you stuff about the state of the remote when you last fetched. 因此,它们只会在您上次获取数据时告诉您有关远程状态的信息。 If you really want to know if you should pull, do a fetch first.
如果您真的想知道是否应该拉,请先进行提取。
If for some reason you do not want to do a fetch (I can't think of a good one), have a look at git ls-remote
. 如果由于某种原因您不想进行获取(我认为还不错),请查看
git ls-remote
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.