简体   繁体   English

git checkout其他用户的本地仓库

[英]Git checkout another user's local repo

I am pretty new to GIT. 我对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). 如何签出或复制另一个用户的本地SHA(已提交但未推送)。 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. 检出仅更改您当前用作HEAD的引用。

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. 就像从Github之类的地方进行克隆一样,这将为您留下一个名为“ origin”的远程地址,指向您从中进行克隆的地方。 You can update from that other copy in the usual ways: git fetch , git pull . 您可以按照通常的方式从其他副本进行更新: git fetchgit pull

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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