Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] git and sub-directories



On Sun, Mar 13, 2011 at 8:37 PM, Darren Cook <darren@example.com> wrote:

> I notice I have a .git subdirectory in both the top directory and the
> settings subdirectory. I guess I did "git init" in the settings
> directory first, then added the parent directory later.
>
> So how do I (a git beginner) fix this mess? Just deleting settings/.git/
> is bad as then I'd lose some commit history?

It depends on what you want to do with your history, and how bad
you want to keep it.  I assume you only have one branch in settings.
If you have more than one you want to save, you'll need to specify
each branch to fetch command separately.

First :-)

rsync -a top /tmp/saved.top

Then you could try (in top)

git fetch settings
git rebase --root --onto master FETCH_HEAD

This will probably put all files in top/settings in top.  Then rm -rf
settings, mkdir
settings, and git mv all those files back into settings.

You could probably do some magic with filter-branch to avoid the ugliness of the
git mv step, but I don't have time for that right now.  The idea is to
use --tree-filter
to mv the files, but that will require some non-trivial scripting to
identify the right ones.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links