Link to home
Start Free TrialLog in
Avatar of infotechelg
infotechelgFlag for United States of America

asked on

Visual Studio - Git Branching Error

I'm new to, and using Git. I have my remotes/origin branch of "master" that contains all production-ready code.

From "master", I create a new local branch called "Bug Fixes".

When I try to push code changes in Bug Fixes back to "master", I get this error every time:

Error encountered while pushing to the remote repository: Not a valid reference 'origin/master'

Maybe I'm not using this correctly? Can someone please advise?
Avatar of Ferruccio Accalai
Ferruccio Accalai
Flag of Italy image

did you commit your changes?
git commit -m "first commit"

Open in new window

Avatar of infotechelg

ASKER

Ferruccio,

Thank you for the reply.

I'm using Visual Studio to do all my commits, pushes, syncs. I'm sorry, I should have mentioned that originally.

But yes, all my changes are committed.
I should also point out that if I right-click on my local branch in Visual Studio under "Branches" in Team Explorer and do a Push, this is where it fails. If I go to "Sync" and do a Push under Outgoing Commits, it works fine.
Avatar of pepr
pepr

You cannot push from one branch to another branch. You have to switch to master branch and then merge the Bug Fixes branch.
Awesome! I'll give that a shot.
Pepr,

Let me ask you this. What is the point, then, of having a "Push" option if you can't push changes from your local branch back to the server branch from where the local branch originated? Seems kind of counter-intuitive. What is "push" for, then?
Pepr,

So, I tried as you suggested. I cannot do as you suggested. I cannot make branches in "remotes/origin" active in order to do a "merge from". I can only merge from remotes/origin into my local branch.

What you suggest works locally. But my problem is pushing the local changes back into the master, remote branch.
ASKER CERTIFIED SOLUTION
Avatar of pepr
pepr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much for the detailed explanation! A huge help.
I should also point out that if I right-click on my local branch in Visual Studio under "Branches" in Team Explorer and do a Push, this is where it fails. If I go to "Sync" and do a Push under Outgoing Commits, it works fine.

This is also happening to me!
It is again a stupid bug on the part of Git extension for Visual Studio. Thank you for suggestion that I can make the push happen under Sync-Push command flow