简体   繁体   中英

Fetching a specific GIT revision to my local repository

I'll start from saying that I've using mainly SVN and our project moved recently to Git. I figure out 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

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM