David
David

Reputation: 36354

Rollback commit in .GIT

I've just pulled on the live server some changes that I don't want on there yet. I need to rollback to the previous version before the last pull.

But i'm not sure of the correct command or how to get the hash for the previous commit that I want to rollback to. Any help much appreciated.

I managed to rollback the head with the following command

git reset --hard HEAD^

Which put my head back to the right point.

But it still appears to have pulled down the changes on the server and I need to now remove the files.

I also have just tried

git clean -f

Which I thought from reading would remove the unwanted added code and files. Seems to have removed the files, but not the code in existing files.

Upvotes: 0

Views: 246

Answers (1)

araqnid
araqnid

Reputation: 133492

git reset --hard should have resynced your workspace to previous commit you rolled back to, so what do you mean by "I need to now remove the files", exactly? Yes, git will have the new change from the remote server tracked in origin/master, but that shouldn't be a problem. Is git diff or git status showing differences? If so, git reset HEAD -- ., git checkout -- . will revert everything.

Upvotes: 1

Related Questions