How to fix "cannot be resolved to branch" on git push?
The common issue is case mistake. I got the same issue before. The better way to do it is to check what are the branch names:
$ git branch
you can compare the branch on above, then push it with the name you got.
$ git push origin Branch2
$ git push origin branch1
In addition to Kyle's answer,
In cases where you already have a branch name like "BugFix/item001" and pushed it to your repository, and then you created another branch with the name "Bugfix/item002", you will still get the same error even if you try to push the branch with the correct casing. I believe this is because of the "BugFix" folder being created already and future branches will use the same folder.
It is still a casing mistake but really misleading.
My branch name was feature/S212121_TestCase_review_Dashboard
When I try to push code to this branch feature/S212121_TestCase_review_Dashboard by using following command:
git push origin feature/S212121_TestCase_review_Dashboard
fatal: feature/S212121_TestCase_review_Dashboard cannot be resolved to branch
Then I have renamed the my branch using following command:
git branch -m TestCase_review_CWLA_Dashboard
After that I have used following command to push the code:
git push --set-upstream origin TestCase_review_CWLA_Dashboard
This works for me I am able to push the code to branch.
It might be because you are not in the latest master branch.
For this you could check with terminal commands on the master branch:
git pull origin (master branch)
and checked your branch.
I created a new branch
git checkout -b newbranch
and pushed to a new branch from the old branch that "has cannot be resolved" error using:
git push origin newbranch
This worked for me.
Related videos on Youtube
Matt Kuhns over 1 year
When I do a
git status, I get my branch:
$ git status On branch OfflineLoading
When I tried to
git push, I get:
$ git push origin OfflineLoading fatal: OfflineLoading cannot be resolved to branch.
When I check the branches, it is not there:
$ git branch branch1 branch2 branch3 branch4
How do I fix this?
Hime over 7 yearsDid you create and changed your work to your new branch? This can be helpful: stackoverflow.com/questions/11860362/…
Pankaj Singhal over 7 yearsI guess you might be doing some spelling mistake / case mistake. Ideally, it should make the remote branch if it doesn't exist or push to remote branch if it exists. Your command seems correct
Matt Kuhns over 7 yearsI checked the spelling and it is right. Do I need to set upstream?
Yuri G. over 7 yearscan you post the output of
git show-ref | grep -i OfflineLoading
k0pernikus over 7 yearsIs the local branch tracking the upstream one?
torek over 7 yearsHow did you create this branch
OfflineLoading? Specifically, did you use
git checkout --orphan? If so, that's the problem: orphan branches aren't actually created until you commit something into them. If not, something is seriously wrong on your computer / in your repository.
Jeff Puckett over 7 yearsAlso please share what version of git, operating system, and if/what git GUI you're using.
Matt Kuhns over 7 yearsThanks for all the responses. I just bit the bullet and saved off my repo and cloned again. Then I overlayed files with my saved directory. Not elegant, but did the trick.
shashikant kuswaha over 2 yearsmost of the time it changes the first letter with caps , you try by doing ``` git branch``` and search your branch and then checkout that branch and then do the
DawnSong almost 4 yearsCorrect answer. My solution is renaming the old branches to something else, then renaming them back. It's caused by "git case sensitivity" problem.
SwissNavy about 2 yearsexactly my case, the suggested workaround worked.
José Veliz about 2 yearsThis works for me thanks!
Admin almost 2 years