David
David

Reputation: 10738

git branch merging

I'm going through a tutorial and it said this command, "git branch -a" would list all my remotes, both local and remote. So i did that and this is what i got.

David-Adamss-MacBook-Pro:releventz davidadams$ git branch -a
* master
  remotes/flashdrive/master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
David-Adamss-MacBook-Pro:releventz davidadams$ 

Master is the branch i'm currently on and is green. All three remote branches are red. I had a little trouble when i was trying to get the path right to my remote to add and push to. Could that be a reason i have three remote branches instead of just one? I just added 'flashdrive' as my remote and pushed to it. So i know that's the most recent but what are the other two?

Upvotes: 1

Views: 469

Answers (3)

lilorox
lilorox

Reputation: 165

You can see more information on your remote repositories by running

git remote -v

This will list the repositories and where they actually are.

Upvotes: 0

VonC
VonC

Reputation: 1324258

I just added 'flashdrive' as my remote and pushed to it. So i know that's the most recent but what are the other two?

Note that your local branch master isn't currently tracking a remote master branch (either remotes/flashdrive/master or remotes/origin/master).
That can lead to an issue with latest git1.8.0: "Git 1.8.0: fatal: The current branch master has multiple upstream branches, refusing to push"

remotes/origin/HEAD is a symbolic HEAD that you can change.
See "How does origin/HEAD get set?".

origin/HEAD represents the default branch on the remote, i.e. the HEAD that's in that remote repository you're calling origin.

When you clone your repo, you will checkout by default the branch that your current remotes/origin/HEAD is referring to.

Upvotes: 0

Clement Herreman
Clement Herreman

Reputation: 10536

origin is the default name of the git remote repository from where you clone your local repository.

  • remotes/origin/master: the master branch from the origin repository.
  • remotes/origin/HEAD -> origin/master: the HEAD branch, a kind of branch that represent *the current branch** (in fact that's not true but it's a little more complicated, see What is HEAD in Git?)

Obviously, the last branch, is a remote master branch, located on the remote repository you just added.

Upvotes: 2

Related Questions