! [rejected] master & # 8594; master (non-fast-forward) on a new updated branch

In my repo, I have a master branch and a new branch.

I have been working on new for some time, committing and pushing when I go. Now I decided to disable new and name it newest . Therefore i did

 git checkout -b "newest" 

and the branch was successfully created. I added the file and started working on it. I made my changes a couple of times.

BUT, when I try to push this new branch and my changes to its origin , I get this error:

 C:\wamp\www\myproj>git push origin To https://github.com/Imray/Proj.git ! [rejected] master -> master (non-fast-forward) ! [rejected] new -> new (non-fast-forward) error: failed to push some refs to 'https://github.com/Imray/Proj.git' hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. Check out this branch and integrate the remote changes hint: (eg 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

So, as indicated in the instructions, I tried git pull , but then I got:

 There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details git pull <remote> <branch> If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/<branch> newest 

I am stuck.

How do I push my new branch and changes on github ?

+5
source share
2 answers

Check out git config push.default . It may be on " matching " as it tries to push all existing branches.
This was the default before Git 2.0+ .

I would recommend setting it to " simple " to push only the current branch.

To say that you need to push a branch, you need (for the first push) to set the branch upstream .

For a branch that has never been clicked:

 git push -u origin newest 

For a branch that exists on an upstream repo :

 git branch --set-upstream-to=origin/master master git branch --set-upstream-to=origin/new new 

Then a git checkout master ; git pull would git checkout master ; git pull would .

+2
source

try the following:

hope this helps

0
source

Source: https://habr.com/ru/post/1210216/


All Articles