0

My dedicated server crashed a day ago due to SSD failure. The hosting company restored my server to 2 days old backup.

The git on the build is now comparing the current changes to 2 days old changes and tracking the newly created files as deleted. How can I resync the build on my server to the latest build on git?

Zain Sohail
  • 464
  • 5
  • 22

3 Answers3

0

With the sequence of actions you mention, if you had some extra modifications on your master branch during the 2 days, you have deleted them from your master branch.

Fortunately, if this was the case, you can still find your commits from your local repo :

  1. run git reflog master

    you should see an output looking like :

    110f738 (HEAD -> master, bare/master) master@{0}: reset: moving to origin/master
    224e68f master@{1}: commit: **commit message**    # <- this commit
    1a58e62 master@{2}: commit: **commit message**
    ...
    
  2. You can use the hash of the commit appearing right before the reset: moving to origin/master line

    running for example :

    # assuming you are on your local 'master' branch :
    
    # re-set master to its previous state :
    git reset 224e68f
    
    # push it to your server :
    git push origin master
    
LeGEC
  • 46,477
  • 5
  • 57
  • 104
0

A non destructive sequence of actions would be :

  1. Fetch all changes :

    git fetch --all
    
  2. Update the remote master branch :

    git push origin master
    
  3. Update any other relevant branch :

    git push origin my/feature1
    git push origin my/bugfix
    
LeGEC
  • 46,477
  • 5
  • 57
  • 104
-1

Following fixed my issue (considering master is your branch):

  1. First fetch all changes:

    git fetch --all

  2. Then reset the master:

    git reset --hard origin/master

  3. Pull/update:

    git pull origin/master

Ref: Git Pull While Ignoring Local Changes?

Zain Sohail
  • 464
  • 5
  • 22
  • warning : this sequence of actions will also delete the changes you have made locally since the restore date – LeGEC Jan 21 '19 at 08:20