Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git remote branches not listed

So I'm trying to create a remote branch so I can push updates to a project I'm doing to my Github account, but for whatever reason, my remote branches aren't being created.

These are the commands I am running:

git remote add origin [email protected]:<username>/first_app.git
git push origin master

After running the first line, everything seems to work fine and I don't get any error messages. BUT, when I check what remote branches I have, nothing will show. The command I ran for that was:

git branch -r

Ignoring that I figured I would at least try the second command from above. When I did, naturally, it says:

ERROR: Repository not found

If someone could help me figure this out it would be greatly appreciated. I've been trying to find information on this online but haven't run into anything yet.

like image 865
Shawn Taylor Avatar asked Nov 11 '12 09:11

Shawn Taylor


People also ask

Why can't I see a remote branch git?

To see local branches, use the git branch command. The git branch command lets you see a list of all the branches stored in your local version of a repository. To see the remote branches associated with your repository, you need to append the -r flag to the end of the git branch command.

How do I see remote branches in git?

To view your remote branches, simply pass the -r flag to the git branch command. You can inspect remote branches with the usual git checkout and git log commands. If you approve the changes a remote branch contains, you can merge it into a local branch with a normal git merge .


1 Answers

After you add remote, git does not have any knowledge about remote branches yet. In fact, remote URL could be very well invalid.

git fetch command is designed to do the following:

  1. Try to communicate to remote and get list of branches on that remote. Snapshot of this information is stored locally in .git/refs/remotes/remotename and is not updated until next git fetch.
  2. Get all new git objects for that remote and selected branch (or all tracking branches).

In other words, doing git fetch is almost mandatory for you.

By the way, git pull = git fetch + git merge, so doing git pull will also accomplish what you want.

like image 118
mvp Avatar answered Oct 06 '22 00:10

mvp