5

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

4
  • what does git remote -v say? Commented Jan 29, 2015 at 15:05
  • git remote -v shows origin user@myserver:/repopath/gitname.git (fetch) and origin <same address above> (push) Commented Jan 29, 2015 at 15:10
  • Well, i was able to see my new branches if i made a new local clone of the remote repo. so i guess that proves the branches are on the remote, just not from the local repo folder i was using. Commented Jan 29, 2015 at 15:14
  • 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. Commented Jan 29, 2015 at 15:20

3 Answers 3

4

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). 
Sign up to request clarification or add additional context in comments.

1 Comment

tried this on the existing repo, didn't change behavior. I also made a new branch and pushed using --set-upstream but same issue. However, on a newly cloned folder from the same remote all worked fine. I am thinking my local repo must have been corrupted somehow., thanks
0

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

Comments

-2

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.