1

I checked out the code from the master branch for my new requirement implementation. After the checkout, I created another branch as git new branch "feature_branch".

But after making changes, I staged all the changes and committed them into the branch (currently, it is not pushed into the remote branch yet).

And when I was trying to push into the remote feature branch (considering that feature branch will be created in remote), but it is trying to push into master. Why, it should not push my feature branch code into the master one. Once I will push the code into the feature branch, then someone can review and merge it into the master.

While push I am getting this pop up: enter image description here

The current snapshot of all branches I have, the red one is the one feature branch which I wanted to push into remote as is, the yellow one is the other branches: enter image description here

Please correct me if I am doing something wrong here. I am using Visual Studio Code to do everything.

2 Answers 2

3

I guess you created feature_branch by git checkout -b feature_branch origin/master. If so, feature_branch tracks master from origin. When you run git push or push via VS code, it's equivalent to git push origin feature_branch:master.

Run git config branch.feature_branch.merge. If it returns refs/heads/master, run git config branch.feature_branch.merge refs/heads/feature_branch and push again.

If it doesn't work, try git push origin -u feature_branch:refs/heads/feature_branch in the command line.

Sign up to request clarification or add additional context in comments.

7 Comments

Yes, you are right I check out my feature branch from master only which is first half, but when I ran second half for git config nothing appears on the screen, I also tried after that as well but no luck, I updated my question with a response I am getting whiling doing push.
@IndrajeetGour How about git push origin -u feature_branch:refs/heads/feature_branch?
I tied it, but it was throwing me an error : "error: src refspec feature_branch does not match any. error: failed to push some refs to master one"
@IndrajeetGour replace feature_branch with the real name of your feature_branch.
Yes, I did replace with my feature branch. Added screenshot for my available branches as well in main question.
|
0
  1. checkout the feature branche using git checkout feature_branch.
  2. verify that your commits are there with git log.
  3. push your feature branch to server with git push -u origin feature_branch.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.