Git push branch error

The script is simple. From the wizard , I have a branch named myBranch . All the time I work in the latter. After I made some changes, I want to push my changes from my local copy of myBranch to the remote branch myBranch . Every time I try to do this, I get the following error / warning message

To git@github.com:brabbit/projectA.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:brabbit/projectA.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

So, I continue to work with git pull, which works fine. Then try again with git pushand the same error will appear.

Could you explain to me what the message means and how to solve it. I am new to git.

+4
source share
3 answers

. - master, , . Git push.default matching, , git push, , . , , , .

, master , master . , Git master . , ( ) Git .

, push.default upstream, simple current:

git config push.default upstream
git config push.default simple
git config push.default current

git-config ( "push.default" ). :

git help config

git push , , .

, git push --force, , . , , Git 2.0 - , .

+6

myBranch, , :

git push origin myBranch

, , :

git config push.default current

, :

git rebase origin/master master
git push origin master
+3

It looks like your branch is not set up well for git pull. In case you just want to push a bunch of simple commits (no merge compliments), I would suggest using git rebase:

git checkout master
git rebase origin/master
git push

If your changes contain a commit, and you want to push it, as you see it in the history ( gitk --all), you can do

git checkout master
git merge origin/master
git push
+1
source

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


All Articles