I\'m new to GitHub. Today I met some issue when I was trying to push my code to GitHub.
Pushing to git@github.com:519ebayproject/519ebayproject.git
To git@gi
I was getting the above mentioned error message when I tried to push my current branch foobar
:
git checkout foobar
git push origin foo
It turns out I had two local branches tracking the same remote branch:
foo -> origin/foo (some old branch)
foobar -> origin/foo (my current working branch)
It worked for me to push my current branch by using:
git push origin foobar:foo
... and to cleanup with git branch -d
I had a similar issue and it turned out that my workflow for keeping my branch up to date was at fault. I was doing the following:
In my local 'master'
git fetch upstream
git merge upstream/master --ff-only
then back in my local branch
git rebase master
This worked well for a previous git flow but not with github. The git rebase
was the problem here causing issues with syncing (and I'll admit that's something I've had to accept without fully understanding) and unfortunately put me in a position where git push -f
became probably the easiest option. Not good.
My new flow is to update the branch directly using git merge
as follows:
In my local branch
git fetch upstream
git merge upstream/master
No fast forward, as I will have made changes of course in the local branch.
As you can probably tell, I'm no git expert but I'm reliably informed that this workflow will probably avoid the specific problems that I had.
I was getting a similar error while pushing the latest changes to a bare Git repository which I use for gitweb. In my case I didn't make any changes in the bare repository, so I simply deleted my bare repository and cloned again:
git clone --bare <source repo path> <target bare repo path>
If no, you should checkout a new branch with the same name as the remote branch and try push it again.
If you`re not in test branch, first switch to it.
git checkout test
Then open a new branch and name it testing.
git checkout -b testing
Now, it`s time to push it:
git push [remote repo] testing
Another cause of this problem (apparently not so common)...
My server was behind ~12 hours when I did a push
I configured NTP on the server SYNC my clock.
I executed a new git push which led the error discussed in this post.
First and simple solution:
git push -f origin master
.git pull --allow-unrelated-histories //this might give you error but nothing to worry, next cmd will fix it
git add *
git commit -m "commit message"
git push
If this doesn't work then follow along