Hi I am new to Git and try to create a local repository and committed the code but when I am trying to push the code on my push command it give this error
SUMITs-Mac-mini:gitupload sumit$ git push -u origin master
To https://github.com/sumittiwari87/First-Gulp-Lesson.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/sumittiwari87/First-Gulp-Lesson.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
So I have tried to pull the commit changes and agin I get the error.
SUMITs-Mac-mini:gitupload sumit$ git pull origin master
warning: no common commits
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/sumittiwari87/First-Gulp-Lesson
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
fatal: refusing to merge unrelated histories
I do not understand why it is happening.
fatal: refusing to merge unrelated histories
Your branches do not have a common base commit for history. This behavior was allowed by default but was typically not the intended result (different commits).
You could do have --allow-unrelated-histories when you do your merge (a pull is just a fetch + merge by default, could be configured to do a rebase). But usually that's not intended, especially you being new to git (unless you are aware of this behavior and history).
My recommendation would be to look at what your local and remote histories are for this repository: git log --oneline --decorate --all --graph. Feel free to editor your question showing the output of this if you would like assistance in interpreting the output.
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