I have a git repository sitting as ~/a
.
At the same time, I have some stuff from ~/b/content/data/
, which will be updated by another application.
For backup purposes, I would like to add ~/b/content/data/
's stuff into git ~/a
, without moving the folder. And also, of course, without manual copy.
Can I do that? Is it via ln
?
More ways to do it
will do it for one-time use (the pathname you specify is relative to the given worktree)
Check whether the worktree you specify has any nested repositories in it (
find that/path -name .git
), those are also known as submodules and what will be added to your own repository is just the currently-checked-out commit id there.Note that checkout like add is always to the current worktree, so if you do the above command, then commit, then checkout without the override, you'll get
~/b/content/data
's innards checked out under~/a
.If you want to set a persistent worktree for the repository,
or as a relative path (relative to the .git directory)