views:

67

answers:

2

Hi All,

I have a bit of a predicament. Basically I have a local "master" git repository. Every few hours, I 'git push' my changes to a server from which I then pull to my client machines. Well, being the genius I am, I accidentally used GITK to roll back my local "master" repository one version too far.

What are the steps to pull the last committed version back from the server and still have my local version behave "masterfully"?

Best.

EDIT: Excellent answers all. Much appreciated!

+2  A: 

First, stash your existing changes:

git stash

Then, run (considering that the remote from which you want to update your local repository to be named origin):

git remote update origin
git reset --hard origin/master

Apply the stashed changes:

git stash pop
Alan Haggai Alavi
+3  A: 

Assuming your local master is still clean, i.e., no local changes, but some number of commits behind master on the server repo, you need only pull from it:

git pull server master

In the above command, server is the name of the remote that other clients pull from (or you could use its URL instead).

Greg Bacon