Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get remote git branches using Node.js?

I'm using this awesome library called Gift to do all of my standard git things (pulling, reading commits, etc). However, I can't seem to get the remote branches. I believe the git branch -r command will show me the branches, but the format is certainly not machine-readable:

  origin/HEAD -> origin/master
  origin/dev
  origin/gh-pages
  origin/master

I'm wondering how I can go about viewing all of the remote branches that a repository has.

Thanks!

like image 971
Shamoon Avatar asked Jan 23 '13 20:01

Shamoon


People also ask

How do I get branches from remote repository?

If you have a single remote repository, then you can omit all arguments. just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.


2 Answers

I guess the command you are looking for is

git ls-remote origin
like image 81
Chronial Avatar answered Oct 01 '22 07:10

Chronial


To show all of the remote repositories for pushing and pulling, try:

git remote -v

if you want more information on a specific remote and how it relates to your current repository:

git remote show <remoteName>

like image 22
g19fanatic Avatar answered Oct 01 '22 06:10

g19fanatic