1

I've made a bunch of commits in the last day, installing a new extension to my Magento system.

I make these changes locally, then they are pushed to bitbucket, and then to my live/testing server.

My commits are rubbish - I need to go back to how the system was 2 days ago. How can I do that, taking into account the remote servers etc?

When I make a reset commit (hard) on sourcetree, it then wants to pull the remote server back in, as its ahead of us.

egg
  • 373
  • 1
  • 7
  • 15
  • Related: [Revert to a previous Git commit](http://stackoverflow.com/q/4114095/456814). –  Jul 22 '14 at 03:27
  • The version of SourceTree that you're using matters, the OS X version isn't always up-to-date with the Windows version, and vice versa. –  Jul 22 '14 at 03:28

1 Answers1

2

If you are sure, you can, after your local reset, do a:

git push -f
# or
git push --force

That would force the upstream repo to mirror your local history (which you reset to 2 days ago)

That is only problematic if other people have already cloned your upstream repo and were working on it (probably not the case here)

Regarding the live server, it depends on how the commits are push to it:

  • if they are push from your local repo, that means git remote -v should list two remotes (one 'origin', and one with another name like 'live').
    In that case, a git push -f live would work.
  • if they are pulled by the live server from the BitBucket repo, the easiest way would be to access that server and do a git reset there.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • yeah, its just me - so no concerns about others. I could SSH into the live server (it pulls from bitbucket) - is there some special settings for the git reset I will need to do? Thanks! – egg Jul 20 '14 at 08:01
  • @egg no special setting, just the same `git reset` as the one you did locally. – VonC Jul 20 '14 at 08:06