Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bring git repo up to a certain revision

Tags:

git

I have a git repo, and a revision code I want it to get my local clone to. How can I bring it up to a specific revision and get rid of any changes I've made?

like image 981
zak23 Avatar asked May 20 '09 20:05

zak23


People also ask

How do I change a repo to a specific commit?

With the new git switch command, we can either: git switch -c <new-branch> <commit> to create a new branch named <new-branch> starting at <commit> git switch --detach <commit> to switch to a commit for inspection and discardable experiments.

How do I get a previous version of a repository?

Reverting To An Old Version of the RepositoryStart by navigating to the “History” tab. Right-click on the previous commit, and you'll see the option to revert this commit. If you click on Revert This Commit , two things will happen. The first is that the files in your repository will revert to their previous state.


1 Answers

Checkout the branch you want to mess with. Find the revision that you want in the log, then do:

$ git reset --hard abcd93

With abcd93 being whatever version you found in the log. Note though, that this will change the branch pointer.

It is usually best to spawn off a new branch, so consider

$ git checkout abcd93 -b new_branch_name
like image 179
Jeff Ferland Avatar answered Sep 20 '22 08:09

Jeff Ferland