如何将本地 git repo 从一个硬盘移动到另一个硬盘?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10774008/
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
How to move local git repo from one hdd to another hdd?
提问by Jay
I'm currently setting up git on one of my local hdds, but will eventually be moving all my git repos on to another hdd (I want to split my work files from my own files, but I do not have the drives yet). Would it be possible to move those local work git repos to the new hdds by just dragging and dropping?
我目前正在我的一个本地硬盘上设置 git,但最终会将我所有的 git 存储库移动到另一个硬盘上(我想将我的工作文件与我自己的文件分开,但我还没有驱动器)。是否可以通过拖放将这些本地工作 git repos 移动到新的硬盘上?
I have a Mac OSX Lion, and am setting up local repos for multiple macs that use my home NAS server as the mothership. I am still a beginner at this git stuff, so any tips are much appreciated. Thanks!
我有一个 Mac OSX Lion,并且正在为使用我的家用 NAS 服务器作为母舰的多个 mac 设置本地存储库。我仍然是这个 git 东西的初学者,所以非常感谢任何提示。谢谢!
回答by devsnd
Yes, you can simply copy all the files to your other computer. But make sure to also copy the "hidden" files, meaning the files that names are starting with a dot.
是的,您只需将所有文件复制到另一台计算机即可。但请确保同时复制“隐藏”文件,即名称以点开头的文件。
Here's a link to a Page describing how to make the hidden files appear in the finder.
这是一个指向描述如何使隐藏文件出现在 finder 中的页面的链接。
Each and every git-repository has a hidden folder called .git
in its top-most directory. This folder contains all the history, revisions and so on. Inside that folder you can also find a file called config
, that you could modify to your wishes after moving the repository.
每个 git-repository 都有一个隐藏文件夹,.git
在其最顶层目录中调用。此文件夹包含所有历史记录、修订等。在该文件夹中,您还可以找到一个名为 的文件config
,您可以在移动存储库后根据自己的意愿修改该文件。
So basically this .git
folder is everything that makes the difference between your bare project files and a git-enabled repository.
所以基本上这个.git
文件夹是你的裸项目文件和启用 git 的存储库之间的区别的一切。
回答by xeed
The git-data is stored in (invisible) folders in your git repo... so if you move the whole folder everything is alright. In Linux and Windows it does work this way, so hopefully for OSX , too.
git-data 存储在 git repo 的(不可见的)文件夹中......所以如果你移动整个文件夹,一切都会好起来的。在 Linux 和 Windows 中它确实以这种方式工作,所以希望 OSX 也是如此。
You can try it out by creating a repo and move it btw ;)
您可以通过创建一个 repo 并顺便移动它来尝试一下 ;)