On Wed, 13 Mar 2024, Paul M Foster wrote:

Folks:

I have a /home/paulf/stow directory with contains subdirectories for each
of the packages whose dotfiles I want to manage, like:

/home/paulf/stow/alacritty

In each subdirectory, I have all the config files for that packages, under
git management. This means that the directory will look like this:

/home/paulf/stow/alacritty/.git
/home/paulf/stow/alacritty/.config/alacritty/alacritty.yml

This works well with stow (configs are now symlinks in $HOME).

I'd like to copy all of this to a git repo on gitlab. You would think you
could go to the ~/stow directory, "git init", then "git add" each
directory, and all is good. However, git looks inside the directories and
sees there are already .git directories there, and refuses to add the
directories and their contents to its repo. Instead, it wants you to use
"submodules", to wit:

git submodule add ./alacritty

This adds an *empty* alacritty subdirectory to the git repo, which isn't
useful.

I need a way to bring all these subdirectories and their contents under a
git repo so I can send it to gitlab. Any suggestions?

Paul



I don't know exactly how to do it but git filter-branch might get you
started.

You can use that to rewrite the history of each branch so they're now
deeper subdirectories.

Now add a remote with an empty commit on master. git rebase each repo
onto that and push as a branch.

Finally git rebase each branch onto master in turn.

If I've understood your need correctly this should not give any
conflicts.


If you don't want to mess with rewriting history then just regular git
mv, rebase onto common master and rebase each tree in turn. But this
will (IMO) make history harder to understand and any future rebase
cleanups will likely be a disaster.

Tim.

Reply via email to