Reputation: 113
I want to check if a branch on a remote Git repository contains a merged branch with a specific name. For example:
www.example.com:/repo.git
.myBranch
.myFeatureBranch
has been merged into myBranch
.If I cloned the repository and checkout myBranch
, I could do git show-ref --verify refs/heads/myFeatureBranch
, but that's not what I want to do. I have to do it with a remote branch without cloning.
I already played around with git ls-remote --heads www.example.com:/repo.git
, but the only thing I get is a list of remote heads. Has anyone done that before?
Upvotes: 7
Views: 3048
Reputation: 84343
The distributed nature of Git is fundamentally designed around a couple of fundamental concepts:
What this means is that exploring history is a local operation, and can't be performed on a remote repository.
The git-ls-remote command is useful in searching upstream for refs, but not for history. For example:
git ls-remote origin | egrep 'some_branch_name|merge'
will print refs on the remote that match the named branch you're looking for, or (in the case of GitHub) refs created from merged pull-requests such as:
381a77fd72ea594cfce5c82c845ad3d10bb87d71 refs/pull/99/merge
The git-ls-remote command displays refs available in a remote repository along with the associated commit IDs. However, if you want to find out what branch contains a given commit, you need access to the full history; that requires you to have a local copy.
The best way I know to deal with this issue is the following:
git fetch --all origin
.git log --merges
.git branch --all --contains <commit>
.This will give you a list of branches that contain the specified commit.
Upvotes: 1
Reputation: 129526
You can't execute commands on the remote. It is simply a sync mechanism. You will need to clone to execute the regular commands.
You may want to look up git branch -a --contains
Upvotes: 1