I made some changes to the code.
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '.....' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
remote: Counting objects: 42, done. remote: Compressing objects: 100% (26/26), done. remote: Total 26 (delta 17), reused 0 (delta 0) Unpacking objects: 100% (26/26), done. From ...... * branch
master -> FETCH_HEAD
Already up-to-date.
Already up-to-date.
Already up-to-date. Yeeah!
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '....' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
So the same again.
What's going on? With git pull it works, but I read it's better to use fetch/merge, so please tell me what am I doing wrong.
git pull will lead to exactly the same result as a git fetch and git merge.
git fetch works a bit different depending how you call it.
Usually you just call git fetch. This will update all remote branches from origin.
Afterwards your own branch is still master while the remote branch is origin/master, hence if you want to merge origin/master into master you have to checkout master and git merge origin/master.
git fetch origin master will just fetch that one branch and store it into a temporary branch called FETCH_HEAD. you could merge it using git merge FETCH_HEAD.
But you probably only want to do a simple git pull. ;)
Hint: use git branch -av to see all your local and remote branches.
What branch do you have checked out? git merge origin/master master does not target master: You always merge to the current branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With