No announcement yet.

Remote Repository Problem

  • Filter
  • Time
  • Show
Clear All
new posts

  • Remote Repository Problem

    Something has happened to my remote repository. I have a local repository that is correct. The latest git log shows:

    commit b688ba891d13e44aae747a62b7aaac41ed510afa

    So then I did 'git push origin --force'

    I then went to another local repository and did 'git reset --hard HEAD'

    When I look at that log the latest entry is:

    commit 902d8ba95e577da6dd1644b5f4c223f7ef5d7bd8

    Although there were no errors with either operation, this local repository is not the same as the correct local repository. Either the push --force did not work or the reset. Either the remote is wrong or this local is wrong. Can someone help me straighten this out? TIA.

  • #2
    In general, you shouldn't be using "--force" when pushing upstream to your remote - that can and will cause other clones to become stranded (requiring work to re-integrate).

    And you didn't state which branch those 2 different local clones were working on. I'll assume they're on the same branch.

    So when you did the "git push origin --force" you modified the remote repository to match the 1st local clone (at least for that branch).

    You stated that you then went to the 2nd local clone and did a "git reset --hard HEAD" - but the "git reset" operation does not talk to the remote at all. It resets the working copy to the head (the --hard means that it will clobber any changes that you've made in the working area and staging area that have not been committed into HEAD).

    What you need to do is update the 2nd local clone i.e. either "git fetch" or "git pull" (a combo of "git fetch" followed by "git merge").


    • #3
      Yes, the only reason I used --force is because the remote is messed up. When I did git fetch it was not what I expected but I think I can untangle this mess now. I can see the commit I want to go back to. Having the string for those commits that were done after the commit I can use git revert to get rid of them in the local repository. But how do I push that back to the remote (use --force again)?


      • #4
        Yes, use the "--force" option again. Another way to do this is here: