简体   繁体   中英

Git checkout another user's local repo

I am pretty new to GIT. I am in a situation where I need to replicate my colleague's local repo. How do I checkout or replicate another user's local SHA (committed but not pushed). I tried

git checkout <sha1>

But got the following error

fatal: reference is not a tree:<sha1>

git checkout <sha1> <path to user's work area>

Got the same error.

Is this even possible ?

You need to clone , not do a checkout. A checkout just changes the ref you are using as HEAD currently.

git clone <path to user's work area>

eg

git clone /home/otherguy/the_project

This is assuming you have read access to the other user's files. Standard filesystem permissions apply here.

This will clone the repo and committed items. Things that are only staged but not committed would not be pulled over, I think. And things not even staged would also not be cloned.

Just like cloning from someplace like Github, this will leave you with a remote named 'origin', pointing to the place you cloned from. You can update from that other copy in the usual ways: git fetch , git pull .

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