When i type git push origin master
the following error message is shown from git:
To https://github.com/farrasdoko/RumahSakit.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/farrasdoko/RumahSakit.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.
Then, i type git fetch origin
, git merge origin master
& git pull origin master
the following error message is shown from git:
From https://github.com/farrasdoko/RumahSakit
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
How to push it??
hint: Updates were rejected because the tip of your current branch is behind
Often when that happens, what you'd really like to do is to add the additional commits in origin/master
into your branch before your own commits. You can use the rebase
command to do that:
git rebase origin/master
That will pull the new commits from origin
into your branch and then add your own new commits on top, so that your commits are the latest. You may encounter some conflicts while rebasing. When that happens, git
will stop and tell you to resolve the conflicts; after that, you should git add
the affected files and then git rebase --continue
. Or, if you decide you don't know how to deal with the problem, you can git rebase --abort
and your branch will be returned to the same state it was in before the git rebase
command started.
git rebase
is a powerful command that can make a quick mess of your branch, so be careful with it, but don't be afraid of it. Standard computing advice applies: back up your work before doing anything if you're not confident. Luckily, it's easy to just make a new branch as a backup (git checkout -b my_backup_branch
) and then switch back to your working 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