Git push won't do anything (everything up-to-date)

后端 未结 16 2197
轻奢々
轻奢々 2020-12-04 05:38

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

相关标签:
16条回答
  • 2020-12-04 06:21

    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.

    0 讨论(0)
  • 2020-12-04 06:27

    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.

    0 讨论(0)
  • 2020-12-04 06:32

    Try:

    git push --all origin
    
    0 讨论(0)
  • 2020-12-04 06:32

    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

    0 讨论(0)
提交回复
热议问题