Reputation: 558
I have added multiple remote in one project. How can check specific branch and push code on that remote with branch.
For Example.
origin https://[email protected]/username/repo.git (fetch)
origin https://[email protected]/username/repo.git (push)
stash http://[email protected]/scm/omed/repo.git (fetch)
stash http://[email protected]/scm/omed/repo.git (push)
Here two remote added. currently i got only origin branch not stash branch.
I want to list all the branches for particular remote.
When I do the git branch -a
I only see branches from origin
I need command for listing down stash remote branches.
Upvotes: 4
Views: 918
Reputation: 14061
Based on Ævar's response to me asking on the Git list: https://public-inbox.org/git/[email protected]/
Is there a command or simple simple invocation of branch, show-ref, for-each-ref, etc that can be give a branch pattern and remote name to quickly filter down the list of potential branches to just one or two 24-line screens?
That's:
git branch -a -l '<remote>/<pattern>'
git for-each-ref 'refs/remotes/<remote>/<pattern>'
The latter will conflate with any local branches you happen to have prefixed with .
The reason this isn't some easy mode in some command is because there's no hard notion that a given remote "owns" a given set of RTB's. It's just convention, but they can and do overlap sometimes.
Remember to use the appropriate * elements into the patterns. It's not a sub-string search.
Upvotes: 1
Reputation: 558
This Steps follow.
1) Fetch the remote information. stash in this case is the remote name.
git fetch stash
2) Display remote branches
git branch -a
3) Now you can create local branch which is tracked by remote branch like following.
git checkout -b <branche-name> stash/<branch-name>
4) Pull or push using the remote name
git pull stash <branch-name>
git push stash <branch-name>
Upvotes: 3