Use the --git-dir
and --work-tree
option of the git command:
If you are modifying files in my_project, but want them taken into account in my-project-repo git repo, you can do:
git --work-tree=/www/my-project/ --git-dir= /github/my-project-repo/.git status
git --work-tree=/www/my-project/ --git-dir= /github/my-project-repo/.git add -A .
git --work-tree=/www/my-project/ --git-dir= /github/my-project-repo/.git commit -m "add files from my-project"
You might want to refresh your working tree in /github/my-project-repo
after modifying its index with your git add
.
cd /github/my-project-repo
git checkout .
Beware though of concurrent modifications you could have on common files: that last checkout would erase and overwrite them by what you added from /www/my-project
.
If you want to be sure to preserve any work in progress in /github/my-project-repo
:
git stash save --keep-index
git stash drop
The OP found a simpler solution, and:
- moved the storage directory to
/www/
.
cd /my-project/
,
git config
, git init
, etc.
I stop tracking the repo that was save on Docs/Github/
— my first storage directory.