2

I am reorganizing my dotfiles and have the following directory structure:

dotfiles
├── .vim
│   ├── colors/
│   ├── ftplugin/
│   ├── pack/
│   │   └── my_plugins/
│   │       ├── opt/
│   │       │   ├── nerdtree/
│   │       │   │   ├── .git
│   │       │   └── vimwiki/
│   │       │       ├── .git
│   │       └── start/
│   │           ├── fugitive/
│   │           │   ├── .git
│   │           ├── syntastic/
│   │           │   ├── .git
│   │           ├── vimade/
│   │           │   ├── .git
│   │           └── vim-css-color/
│   │               ├── .git
│   ├── README.md
│   └── vimrc

There are six directories which are github repos and that have already been cloned to their directories.

I want to now make the entire dotfiles directory version controlled. How do I add the six .../.git repos as submodules to the top level repo, without having to re-clone the packages.

Note that here, a similar question was asked, but the instructions given are unclear. What I need is the step-by-step solution to add the entire .vim directory to the top-level repo.

0

1 Answer 1

7

Here's a step by step process :

# dotfiles directory is current directory
git init 

# Add already cloned repos
git submodule add <github-repo1-link> <path-to-already-cloned-repo1>
git submodule add <github-repo2-link> <path-to-already-cloned-repo2>
.
.
.

# Add other files for staging
git add .

# Commit the changes
git commit

As mentioned in git docs for submodules here, the add command of submodule takes path as an optional argument.

git submodule add <repository> [<path>]

The optional argument <path> is the relative location for the cloned submodule to exist in the superproject. If <path> is not given, the canonical part of the source repository is used ("repo" for "/path/to/repo.git" and "foo" for "host.xz:foo/.git"). If <path> exists and is already a valid Git repository, then it is staged for commit without cloning. The <path> is also used as the submodule’s logical name in its configuration entries unless --name is used to specify a logical name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.