Git clone particular version of remote repository
You could "reset" your repository to any commit you want (e.g. 1 month ago).
Use git-reset for that:
git clone [remote_address_here] my_repo
cd my_repo
git reset --hard [ENTER HERE THE COMMIT HASH YOU WANT]
Use git log
to find the revision you want to rollback to, and take note of the commit hash. After that, you have 2 options:
If you plan to commit anything after that revision, I recommend you to checkout to a new branch:
git checkout -b <new_branch_name> <hash>
If you don't plan to commit anything after that revision, you can simply checkout without a branch:
git checkout <hash>
- NOTE: This will put your repository in a 'detached HEAD' state, which means its currently not attached to any branch - then you'll have some extra work to merge new commits to an actual branch.
Example:
$ git log
commit 89915b4cc0810a9c9e67b3706a2850c58120cf75
Author: Jardel Weyrich <suppressed>
Date: Wed Aug 18 20:15:01 2010 -0300
Added a custom extension.
commit 4553c1466c437bdd0b4e7bb35ed238cb5b39d7e7
Author: Jardel Weyrich <suppressed>
Date: Wed Aug 18 20:13:48 2010 -0300
Missing constness.
$ git checkout 4553c1466c437bdd0b4e7bb35ed238cb5b39d7e7
Note: moving to '4553c1466c437bdd0b4e7bb35ed238cb5b39d7e7'
which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
git checkout -b <new_branch_name>
HEAD is now at 4553c14... Missing constness.
That way you don't lose any informations, thus you can move to a newer revision when it becomes stable.
You Can use simply
git checkout commithash
in this sequence
git clone `URLTORepository`
cd `into your cloned folder`
git checkout commithash
commit hash looks like this "45ef55ac20ce2389c9180658fdba35f4a663d204"