Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Sync to upstream: Newly created branch not showing in my fork

I've two remotes - origin which points to my fork and upstream which points to company repo.

$git remote -v    
    origin  https://github.com/me/app.git (fetch)
    origin  https://github.com/me/app.git (push)
    upstream    https://github.com/company/app.git (fetch)
    upstream    https://github.com/company/app.git (push)

I forked before a month. and I've been pushing to origin and then raising a pull request to upstream. This was fine.

Now someone created a branch called "3D_Theory" in upstream and I want to first reflect that new branch in to my origin and then work off of that branch. But for some reason that branch is not reflecting in my origin.

I tried the following:

git remote show origin
>> does not list 3D_Theory

git remote show upstream
>> lists 3D_Theory

I tried:

git fetch upstream
git checkout master
git merge upstream/3D_Theory

But still I don't have that branch created on my fork. How can I get a new branch on upstream to reflect on my fork?

Thank you

None of the following similar problems helped me:

  • Git checkout: updating paths is incompatible with switching branches
  • https://help.github.com/articles/syncing-a-fork/
  • Can "git pull --all" update all my local branches?
like image 791
Rose Avatar asked Dec 25 '22 19:12

Rose


2 Answers

Yay, I guess this worked.

git fetch upstream 3D_Theory:3D_Theory

git status

git push origin 3D_Theory

If you have a better solution please post it here and I'll try your solution and mark it as the better answer.

like image 103
Rose Avatar answered Jan 18 '23 22:01

Rose


Above will fetch only specified branch. There could be many newly branches created, if team size is large. This can be accomplished by following steps.

  1. This will fetch all upstream branches & show on terminal

    git fetch upstream

  2. This will push the current branch to upstream

    git push origin

like image 23
abhijeet104 Avatar answered Jan 18 '23 23:01

abhijeet104