0

As per the title, I have been working with a git repo on my work system. I would like to work on the same repo at home as well. Would anything go wrong if i just transfer the entire git repo folder onto my external hard drive and work on it between my work and home computer?

I am still in the process of pushing everything on to github, work internet is really slow so bringing it back home to push it to the github repo is another benefit as well.

John Chng
  • 11
  • 1
  • 2
    A git repository is entirely self contained, so there are no problems if you copy the entire folder onto an external drive. – larsks Jul 25 '23 at 20:45
  • 2
    Just be sure you get the *entire* folder, including the hidden `.git` folder and all its contents. – Jim Redmond Jul 25 '23 at 20:53
  • Does this answer your question? [Is a git folder self-contained?](https://stackoverflow.com/questions/14181402/is-a-git-folder-self-contained) – SebDieBln Jul 25 '23 at 21:04
  • Does this answer your question? [Can I copy a Git working copy onto another machine?](https://stackoverflow.com/questions/2042470/can-i-copy-a-git-working-copy-onto-another-machine) – Gino Mempin Jul 26 '23 at 01:36

1 Answers1

2

Yes, you can just copy the .git folder to your hard drive. So when you want to get the exact files, you can copy back the .git folder to your computer and inside the new empty directory, run git checkout . to get the files back.

But the better approach is assume the hard drive directory as a git remote, to doing this, you can make a directory inside your hard drive, run git init on it. Define remote to your hard drive directory path and push your existing repository into that. Therefore in another system, you can pull | clone the repository (directory in your hard drive) and interact with that directory as a git remote

Mehdi Khademloo
  • 2,754
  • 2
  • 20
  • 40