Lee Hampton
Lee Hampton

Reputation: 1109

Setting a branch to a previous commit but keeping subsequent commits

I'm working on a large project that has a 'develop' branch. The develop branch is hooked up to our development server/environment. I recently made some changes that have been pushed to the develop branch, but I want to go back to before those changes to test a certain piece of functionality out. I'm wondering what the least destructive way to do that is. Ideally, I'd just like to revert the branch to that commit for a few minutes, and then return it to my current commit afterwards. I'm using Github.

Upvotes: 0

Views: 67

Answers (1)

FlyingFoX
FlyingFoX

Reputation: 3509

You can use git checkout <commit> to put your working directory in the state it was at any commit. This will not update the HEAD of your develop branch and you can just move back there with a git checkout develop.

You can find out what the sha1 of the commit you are searching is with git log.

Upvotes: 2

Related Questions