简体   繁体   English

如何检查master是否已合并到当前分支

[英]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. fetchpull 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.

相关问题 我如何知道一个分支是否已经合并到 master 中? - How can I know if a branch has been already merged into master? Git:如何删除已经提交,推送并合并到master的分支? - Git: How do I remove a branch that has already been committed, pushed, and merged into master? 功能分支合并到master后,我会继续做什么呢? - What shall I do after my feature branch has been merged into master but I have continued to work on it? 已经与master合并的分支中的错误如何解决? - How to fix a bug in a branch after it has already been merged with master? 如何检查分支是否已合并到另一个分支? - How can I check whether a branch has been merged into another branch? 如何使用 Github API 从合并到 master 的分支中获取 PR 信息? - How do I get the PR information from a branch that's been merged to master using the Github API? 如果其他分支已合并到主分支,如何将我的分支合并到主分支 - How to merge my branch to master if some other branch has been merged into the master 检查分支是否已合并为主分支并且尚未恢复 - Check if a branch has been merged to master and hasn't been reverted out 如何查找分支是否已合并到任何分支(不仅是特定分支) - How do I find if a branch has been merged to any branch (not just a specific one) 如何将尚未合并到master中的远程分支拉到本地分支中? - How to take a pull of a remote branch that has not been merged into master into a local branch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM