Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Synchronize git workspace with another folder

Tags:

git

Is there a standard way for synchronizing git workspace with another directory. Suppose I have a directory that is under git version control. That directory is taken offsite and changes and done to it (files are changed, added and deleted). Then it is returned to my machine. How can I easily integrate all of these changes back into git.

If I were just to copy files over then new and changed files would be fine but information about removed files will be lost. Is there any way to easily do git rm on files that were removed while directory was outside of git?

like image 207
Ghostrider Avatar asked Apr 12 '14 11:04

Ghostrider


1 Answers

VonC's answer looks like the 1st part of what you want.

The --work-tree option is described on the git(1) Manual Page

However after running git --work-tree=/path/to/your/other/directory add -A . your index is different from your local (original) directory. To make the local directory match the index (that contains all the changes from the offline directory) run git checkout ..

git --work-tree=/path/to/your/other/directory add -A .
git checkout .
like image 120
Mike Lippert Avatar answered Sep 21 '22 00:09

Mike Lippert