How to move local git repo from one hdd to another

2019-02-04 12:28发布

问题:

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?

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!

回答1:

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.

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.

So basically this .git folder is everything that makes the difference between your bare project files and a git-enabled repository.



回答2:

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.

You can try it out by creating a repo and move it btw ;)