I\'m trying to push my project (all files in a new repository). I follow the steps but when I push with git push -u origin master
I get this error:
I've just received this error.
I created a github repository after creating my local git repository so I needed to accept the changes into local before pushing to github. In this case the only change was the readme file created as optional step when creating github repository.
git pull https://github.com/*username*/*repository*.git master
repository URL is got from here on project github page :
I then re-initialised (this may not be needed)
git init
git add .
git commit -m "update"
Then push :
git push
I had same as issue. I use Git Totoise. Just Right Click ->TotoiseGit -> Clean Up . Now you can push to Github It worked fine with me :D
You need to do
git branch
if the output is something like:
* (no branch)
master
then do
git checkout master
Make sure you do not have any pending commits as checking out will lose all non-committed changes.
Try this, in my case it works
git rebase --abort
use this command:
git pull --allow-unrelated-histories <nick name of repository> <branch name>
like:
git pull --allow-unrelated-histories origin master
this error occurs when projects don't have any common ancestor.
My Remote was not in sync with the local so this worked for me
git pull --rebase
and make sure when you do git pull
again it should say Already up to date
and now you are ready to push to origin
assuming you have already git remote add origin remote repository URL
do
`git push origin master`
The Screenshot says it all