I'll start from saying that I've using mainly SVN and our project moved recently to Git. I figure ou开发者_StackOverflow社区t that I don't really understand lot of GIT principles.
My question is practical:
We have a GIT repo hosted on a central place (Beanstalk) and all of us push and pull there.
Now, my local repo got broken, and I need to recreate it. But not the latest revision but a specific one in the past (bc213be6
, just an example).
How can I accomplish this?
I would clone the central repository but, as I said above, I need the none latest version.Thanks
Gidi
Cloning will get you the full history. Then you can choose any revision you want to see in your working tree.
Rather than a reset, I would do a git checkout
to the right ('bc213be6
' for instance, or the right tag if there is one):
git clone git://git.myserver.org/myrepo.git
cd myrepo
git checkout <sha1>
But if you want to do any modification, create a local branch:
git checkout -b myBranch <sha1>
If you don't, you would be in a DETACHED HEAD.
Note that you have many way to specify your revision, as explained in git rev-parse
.
Do a git clone first. Afterwards use a git reset to move HEAD to the commit you want.
Here's the link to the git manual for the reset: http://git-scm.com/docs/git-reset
精彩评论