I\'ve edited my GIT repositories via Git Online. After I tried to push my local code changes, I got an error:
Git push failed, To prevent from losing histor
I encountered the same error, just add "--force" to the command, it works
git push origin master --force
I've hade the same problem. I resolved with
git checkout <name branch>
git pull origin <name branch>
git push origin <name branch>
You can add --force-with-lease to the command, it will works.
git push --force-with-lease
--force is destructive because it unconditionally overwrites the remote repository with whatever you have locally. But --force-with-lease ensure you don't overwrite other's work.
See more info here.
Add --force to your command line if you are sure you want to push. E.g. use git push origin --force
(I recommend the command line as you will find much more support from other users with the command line. Also this may not be possible with SmartGit.) See this site for more information: http://help.github.com/remotes/
Sometimes, while taking a pull from your git, the HEAD gets detached. You can check this by entering the command:
git branch
(HEAD detached from 8790704)
master
develop
It's better to move to your branch and take a fresh pull from your respective branch.
git checkout develop
git pull origin develop
git push origin develop
I've had the same problem.
The reason was, that my local branch had somehow lost the tracking to the remote counterpart.
After
git branch branch_name --set-upstream-to=origin/branch_name
git pull
and resolving the merging conflicts, I was able to push.