19

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!

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Jay
  • 1,084
  • 4
  • 18
  • 43
  • possible duplicate of [Moving a git repo to a second computer?](http://stackoverflow.com/questions/5851966/moving-a-git-repo-to-a-second-computer) – James Lawruk May 04 '13 at 14:39

2 Answers2

39

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.

devsnd
  • 7,382
  • 3
  • 42
  • 50
  • This is one great advantage over TFS for me - When using something like TFS there are bindings stored that point to specific locations on disk. Moving a local copy of a repo in Git is so elegant in comparison – Dan Harris Feb 22 '18 at 13:01
  • Hello @devsnd, I did what you wrote. Copy the project directory - I mean `mv /home/username/proj1 /media/user/abc/another/projects/proj1` but now all off my files are changed and git wants me to commit my changes. It says: `old mode 100644` and `new mode 100755`. I think it is better to update your answer as it is the accepted one to prevent any misunderstanding. [The solution which saves me](https://stackoverflow.com/a/56388238/8784518) – Kasir Barati Mar 22 '22 at 05:24
4

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 ;)

xeed
  • 925
  • 8
  • 22