Reputation: 93
I made a new local branch:
git checkout -b new_branch
then change some files, and commit:
git commit -am "comments"
and then pushed to remote:
git push origin new_branch
It looks like it worked, i see message:
* [new branch] new_branch -> new_branch
i then do:
git branch -a
but i don't see my new branch under remotes/origin but i see it for local. I try a pull,
git pull
and git says everything is "Already up-to-date"
I tried
git fetch --all
same result from
git branch -a
What am i missing? i don't recall having to do anything different in the past.
I want to be able to do things like:
git diff new_branch origin/new_branch
but origin/new_branch doesn't show up All my other branches show up as remotes/origin/branchname
Upvotes: 4
Views: 6904
Reputation: 675
That is sometimes happening and unable to find the remote branch. However, if you follow the link by Github in initial push:
repository_name/compare/branch_name_you_are_merging_to...name_of_your_remote_branch?quick_pull=1
I was able to actually PR it even tho I was not able to see the remote branch I pushed.
E.g.
If I trying to push typo_fix branch to next.js's main.
repository_name: https://github.com/vercel/next.js
So, https://github.com/vercel/next.js/compare/main...typo_fix?quick_pull=1
Upvotes: 0
Reputation: 93
All suggestions pointed to the remote repo actually having the correct info. Since a new clone of remote repo worked perfectly and showed previously missing branches, it seems like the behavior is from a some how corrupted local repo.
Thanks for help.
Thanks to:
I have seen this (and other strange) behavior before with Git. It is open source and no law says it will not have any bugs or quirks. When you did a <code>git pull</code> and everything was already up to date, that basically confirmed that the remote branch existed in the origin. – Tim Biegeleisen
Upvotes: -2
Reputation: 9792
The first time you push a branch you should do:
git push --set-upstream origin branch-name
You can do it now if you didn't do it the first time.
-u, --set-upstream
For every branch that is up to date or successfully pushed, add
upstream (tracking) reference, used by argument-less git-pull(1)
and other commands. For more information, see branch.<name>.merge
in git-config(1).
Upvotes: 3