Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have many files in my home directory under git version control.

My emacs setup, zsh source files, PhD thesis, etc.

It's all in one huge git repo at the root of the home directory. (Of course the files themselves are in many different directories.)

I'm considering using filter-branch to split the repo up so my thesis commits aren't polluted with my .emacs commits, etc.

Generally, is this a good idea? I don't want to lose any history.

Will I have to copy my .gitconfig file into each directory that gains a repo?

And, if I accidentally git add foo.txt in a directory before git init, will it be staged in the first repo git finds as it wanders up my directory tree? Or can this be prevented?

share|improve this question

1 Answer 1

If you want to split your repository in several new ones, you won't be able to use filter-branch, since it's basically a powerful rebase that works inside a single repository.

You cannot have several repositories, and still keep the history, since the history is made of commits that touch all the versioned files in your original repository. So I'm afraid you have no other choice but starting the multiple repositories from scratch. You can of course archive the original one in case you ever need to consult it.

I would definitely avoid creating a Git repository anywhere in a working directory, i.e. doing git init in a directory that is already versioned in Git. While this would be possible, it would require extreme caution with the --git-dir and/or --work-tree parameters. Instead, move the $HOME/.git directory to some other directory that won't be versioned before you create the multiple repositories in different directories.

The .gitconfig file is your per-user Git configuration file. By default, it lives in your $HOME. Since your home directory is your working directory, you probably thought you needed one such file in each working directory, but you don't. The per-repository configuration file is .git/config.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.