I\'m trying to update a Git repository on GitHub. I made a bunch of changes, added them, committed then attempted to do a git push
. The response tells me that e
In my case, I had to delete all remotes (there were multiple for some unexplained reason), add the remote again, and commit with -f.
$ git remote
origin
upstream
$ git remote remove upstream
$ git remote remove origin
$ git remote add origin <my origin>
$ git push -u -f origin main
I don't know if the -u
flag contributed anything, but it doesn't hurt either.
Instead, you could try the following. You don't have to go to master
; you can directly force push the changes from your branch itself.
As explained above, when you do a rebase, you are changing the history on your branch. As a result, if you try to do a normal git push
after a rebase, Git will reject it because there isn't a direct path from the commit on the server to the commit on your branch. Instead, you'll need to use the -f
or --force
flag to tell Git that yes, you really know what you're doing. When doing force pushes, it is highly recommended that you set your push.default
config setting to simple, which is the default in Git 2.0. To make sure that your configuration is correct, run:
$ git config --global push.default simple
Once it's correct, you can just run:
$ git push -f
And check your pull request. It should be updated!
Go to bottom of How to Rebase a Pull Request for more details.
Try:
git push --all origin
Thanks to Sam Stokes. According to his answer you can solve the problem with different way (I used this way). After updating your develop directory you should reinitialize it
git init
Then you can commit and push updates to master