Copy git repository to offline machine and pushing/pulling via memory-stick

Beginner picture Beginner · Jan 19, 2015 · Viewed 12.4k times · Source

I need to work on an offline machine, where I cannot access my repository. Now I also don't want miss out on using Git altogether.

Questions:

  • What is the best way to copy my repository onto an offline machine via memory-stick?
  • Is there a way to copy patches via the filesystem?

Edit: I should have stated, that I will have to hand over the memory stick to an administrator who will do the copying for me, i.e. I cannot mount the stick with my user.

Answer

Aaron Digulla picture Aaron Digulla · Jan 19, 2015

To copy a complete Git repo, you just have to copy the folder .git; it contains everything. Git uses safe file names and ignores time stamps inside of the repo, so this data is safe from the usual file system quirks.

On the target machine, create a folder, copy the .git folder inside. Now git checkout <branch> will get you a working copy.

If you want to move patches back and forth instead of the whole repo, then git format-patch <branch> creates them. The command will create all patches necessary to update a remote repo (i.e. the output will contain everything that hasn't been pushed, yet). you can also give it commit IDs (= start with this commit) or ranges.

To apply them, use git am < 0001.... on the remote repo.

Related: