git clone vs 复制粘贴,有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7303765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git clone vs copy paste, what's the difference?
提问by fajrian
as stated in the subject
如主题所述
note: the git clone i mean is the git clone without any option, the one which is performed by doing "git clone /C:/my_origin_folder"
注意:我的意思是 git clone 是没有任何选项的 git clone,它是通过执行“git clone /C:/my_origin_folder”来执行的
采纳答案by manojlds
This answer of mine regarding backup should give you some answer on clone vs copy: Moving a git repo to a second computer?
我的这个关于备份的答案应该会给你一些关于克隆与复制的答案:Moving a git repo to a second computer?
Main differences:
主要区别:
- When you clone, you get remote
origin
setup pointing to original repo, so that you can push to it. - You don't get hooks and reflog ( and also old objects) and other remotes when you clone but you do when you copy
- 当您克隆时,您将获得
origin
指向原始存储库的远程设置,以便您可以推送到它。 - 克隆时不会获得钩子和 reflog(以及旧对象)和其他遥控器,但在复制时会获得
Note that when you clone with a folder path, the differences change subtly, as the objects and refs are usually just copied / hardlinked ( equivalent of --local
which is the default with local folder paths)
请注意,当您使用文件夹路径进行克隆时,差异会发生微妙的变化,因为对象和引用通常只是复制/硬链接(相当于--local
本地文件夹路径的默认设置)
回答by cenanozen
When you use git clone instead of copy paste, the original repository will be the origin.
当您使用 git clone 而不是复制粘贴时,原始存储库将是源。
Besides, when cloning on the same machine you can use --local to make it faster. From the manual page:
此外,在同一台机器上克隆时,您可以使用 --local 使其更快。从手册页:
--local, -l
When the repository to clone from is on a local machine, this flag bypasses the normal "git aware" transport mechanism and clones the repository by making a copy of HEAD and everything under objects and refs directories. The files under .git/objects/ directory are hardlinked to save space when possible....
--本地,-l
当要克隆的存储库在本地机器上时,此标志绕过正常的“git 感知”传输机制,并通过复制 HEAD 以及对象和 refs 目录下的所有内容来克隆存储库。.git/objects/ 目录下的文件被硬链接以尽可能节省空间......