Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot access a git branch from a different computer

Tags:

git

github

Basically i cannot see a branch on a different computer. I run

git branch -a

and on home computer I get

C:\learn ror\sample_app [filling-in-layout]> git branch -a
* filling-in-layout
  master
  static-pages
  remotes/origin/filling-in-layout
  remotes/origin/master
  remotes/origin/static-pages

On the work pc I get almost the same result, except the "filling-in-layout" branches(local and remote).

What should I do?

like image 403
Robin Winton Avatar asked Dec 27 '22 22:12

Robin Winton


2 Answers

To share branches, you need to push your branches on the machines where they're created, and setup remote tracking branches on the other machines:

Try this, on the machine that has the branch:

git push -u origin <branch name>

and this on the machine that doesn't:

git fetch
git checkout <branch name>

Git will automatically set up a remote tracking branch named <branch name> if you try to check out a branch that only exists on a remote.

like image 144
meagar Avatar answered Jan 05 '23 17:01

meagar


When you create a tag or a branch in your machine, and when you want to share your tag or your branch in remote repository, you have to push the tag or branch in the same way you push the repository.

$ git checkout -b new-branch
[...]
$ git add .
$ git commit -m 'Some stuff'
$ git push origin new-branch

And the same with a tag:

$ git tag 6.7
[...]
$ git push origin 6.7
like image 34
sensorario Avatar answered Jan 05 '23 16:01

sensorario