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
Pull changes first:
git pull origin branch_name
This is what worked for me. It can be found in git documentation here
If you are on your desired branch you can do this:
git fetch origin
# Fetches updates made to an online repository
git merge origin YOUR_BRANCH_NAME
# Merges updates made online with your local work
Before pushing, do a git pull with rebase option. This will get the changes that you made online (in your origin) and apply them locally, then add your local changes on top of it.
git pull --rebase
Now, you can push to remote
git push
For more information take a look at Git rebase explained and Chapter 3.6 Git Branching - Rebasing.
(One) Solution for Netbeans 7.1: Try a pull. This will probably also fail. Now have a look into the logs (they are usually shown now in the IDE). There's one/more line saying:
"Pull failed due to this file:"
Search that file, delete it (make a backup before). Usually it's a .gitignore file, so you will not delete code. Redo the push. Everything should work fine now.
Using the --rebase
option worked for me.
git pull <remote> <branch> --rebase
Then push to the repo.
git push <remote> <branch>
E.g.
git pull origin master --rebase
git push origin master
Encountered the same problem, to solve it, run the following git
commands.
git pull {url} --rebase
git push --set-upstream {url} master
You must have created the repository on github first.