Git: check xyz commit in remote repo?

I have an xyz commit in my local branch that I want to check if it is included in the remote version repository; can i do this in several ways? I could clone the remote repo, but I hope for a better and faster way. git ls-remote seemed promising, but found nothing useful for me. Thank!

+44
git
Apr 05 2018-11-11T00:
source share
2 answers

Suppose a remote that references a remote repository is called origin . In this case, first update all branches of the remote tracking using

 git fetch origin 

Now you can use the useful --contains option for git branch to find out which of the remote branches contains this commit:

 git branch -r --contains xyz 

( -r means only show remote tracking branches.) If commit xyz contained in one or more remote tracking branches, you will see output, for example:

  origin/test-suite origin/HEAD -> origin/master origin/master 

If it is contained in your local repository, but is not one of the branches of remote tracking, the output will be empty. However, if this commit is not known at all in your repository, you will get a malformed object name error message and a usage message - maybe a little confusing if you don't expect this ...

+68
Apr 05 '11 at 9:01
source share

As Mark said,

  git branch -a --contains commitish 

However, be careful for branches that contain the selected cherry / reinstall / merged version of the commit.

It may come in handy.

  git log --cherry-pick --left-right <commitish> ^remote/branchname 

It will display the commit ONLY if it does not exist (like cherrypick) in the remote branch. See the log man page for an explanation of how -cherry-pick identifies equivalent commits.

Of course, mergers / recreations with conflict resolution or squash cannot be automatically detected as

+9
Apr 05 2018-11-11T00:
source share



All Articles