Search code examples
gitatlassian-sourcetree

How can I update a remote branch?


Using SourceTree, I reset my local repository to a previous commit. I then used GitBash to do a gitk --date-order to see the commits in the Bare repository which I push to in order to update that to the same previous commit. I did this using git update-ref HEAD [SHA ID]. Both the Bare repository and the one I originally reset have only one branch.

Now I want to update my remote repository back to that previous commit. I am unclear on how to use the git remote commands to do the exact same thing. The wrinkle being that I have two remote branches: development and master. I only pushed those changes I wanted to reset to the development branch (master has not been merged yet).

Can anyone show me the commands to update my remote development branch correctly?


Solution

  • git remote add development E:Code/Code.Website1
    git push development -f
    

    Understand that if you have not backed up the development remote, the history will not be preserved, and you won't be able to get that back.

    Understand that you should not be changing your remote history if your remote is accessible by anyone else.