Skip to content

Instantly share code, notes, and snippets.

@NathanKleekamp
Forked from manasthakur/submodules.md
Created June 16, 2019 15:55
Show Gist options
  • Select an option

  • Save NathanKleekamp/b3d29b585961de90d803e1ad3ac9f855 to your computer and use it in GitHub Desktop.

Select an option

Save NathanKleekamp/b3d29b585961de90d803e1ad3ac9f855 to your computer and use it in GitHub Desktop.

Revisions

  1. @manasthakur manasthakur revised this gist Feb 5, 2017. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions submodules.md
    Original file line number Diff line number Diff line change
    @@ -63,14 +63,14 @@ rm -r .git/modules/pack/plugins/start/foo
    To update `foo`:
    ```
    cd ~/.vim/pack/plugins/start/foo
    git pull
    git pull origin master
    ```
    It is recommended to first `git fetch` a plugin, review changes, and then `git merge`.
    It is recommended to first `git fetch origin master` a plugin, review changes, and then `git merge`.
    To update all the plugins:
    ```
    cd ~/.vim
    git submodule foreach git pull
    git submodule foreach git pull origin master
    ```
    Note that new commits to plugins create uncommitted changes in the main repository.
  2. @manasthakur manasthakur revised this gist Feb 5, 2017. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions submodules.md
    Original file line number Diff line number Diff line change
    @@ -16,10 +16,15 @@ git remote add origin https://github.com/username/reponame.git
    git push -u origin master
    ```

    To enable submodules for plugins (say always-loaded `foo` and optionally-loaded `bar`, located at `https://github.com/manasthakur/foo` and `https://github.com/manasthakur/bar`, respectively) using Vim 8's package feature:
    To enable submodules:
    ```
    cd ~/.vim
    git submodule init
    ```

    ### Installing plugins
    To install plugins (say always-loaded `foo` and optionally-loaded `bar`, located at `https://github.com/manasthakur/foo` and `https://github.com/manasthakur/bar`, respectively) using Vim 8's package feature:
    ```
    git submodule add https://github.com/manasthakur/foo.git pack/plugins/start/foo
    git submodule add https://github.com/manasthakur/bar.git pack/plugins/opt/bar
    git commit -m "Added submodules."
    @@ -45,7 +50,7 @@ git commit -m "Added submodules."
    :helptags ALL
    ```
    ### Removing a plugin
    ### Removing plugins
    To remove `foo`:
    ```
    cd ~/.vim
    @@ -54,7 +59,7 @@ git rm -r pack/plugins/start/foo
    rm -r .git/modules/pack/plugins/start/foo
    ```
    ### Updating a plugin
    ### Updating plugins
    To update `foo`:
    ```
    cd ~/.vim/pack/plugins/start/foo
  3. @manasthakur manasthakur revised this gist Feb 5, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion submodules.md
    Original file line number Diff line number Diff line change
    @@ -75,7 +75,7 @@ cd ~/.vim
    git commit -am "Updated plugins."
    ```
    On another machine, if a `git pull` for the main repository leads to uncommitted changes in the submodules (as a few plugins got updated), perform `git submodule update` to change the state of the submodules.
    On another machine, if a `git pull` for the main repository leads to uncommitted changes in the submodules (as a few plugins got updated), perform `git submodule update` to change the recorded state of the submodules.
    Even though slightly complicated, submodules are a necessary devil when you want to maintain an easily-cloneable `.vim` repository.
    The other option is to _not_ version-control submodules at all by adding a line `pack` in `~/.vim/.gitignore`, and manually add plugins on a new machine.
  4. @manasthakur manasthakur revised this gist Feb 5, 2017. 1 changed file with 10 additions and 8 deletions.
    18 changes: 10 additions & 8 deletions submodules.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    If you work across many computers (and even otherwise!), it's a good idea to keep a copy of your setup on the cloud, preferably in a git repository, and clone it on another machine when you need.
    Thus, you should keep the `.vim` directory along with your `.vimrc` version-controlled.

    But when you have plugins installed inside `.vim/bundle` (if you use [pathogen](https://github.com/tpope/vim-pathogen)) or inside `.vim/pack/plugins/start` (if you use Vim 8's packages), keeping a copy where you want to be able to update the plugins (individual git repositories), as well as your vim-configuration as a whole, requires you to use git submodules.
    But when you have plugins installed inside `.vim/bundle` (if you use [pathogen](https://github.com/tpope/vim-pathogen)), or inside `.vim/pack` (if you use Vim 8's packages), keeping a copy where you want to be able to update the plugins (individual git repositories), as well as your vim-configuration as a whole, requires you to use git submodules.

    ### Creating the repository
    Initialize a git repository inside your `.vim` directory, add everything (including the vimrc), commit and push to a GitHub/BitBucket/GitLab repository:
    @@ -16,12 +16,12 @@ git remote add origin https://github.com/username/reponame.git
    git push -u origin master
    ```

    To enable submodules for plugins (say `foo` and `bar` located at `https://github.com/manasthakur/foo` and `https://github.com/manasthakur/bar` respectively) using Vim 8' packages:
    To enable submodules for plugins (say always-loaded `foo` and optionally-loaded `bar`, located at `https://github.com/manasthakur/foo` and `https://github.com/manasthakur/bar`, respectively) using Vim 8's package feature:
    ```
    cd ~/.vim
    git submodule init
    git submodule add https://github.com/manasthakur/foo.git pack/plugins/start/foo
    git submodule add https://github.com/manasthakur/bar.git pack/plugins/start/bar
    git submodule add https://github.com/manasthakur/bar.git pack/plugins/opt/bar
    git commit -m "Added submodules."
    ```

    @@ -46,7 +46,7 @@ git commit -m "Added submodules."
    ```
    ### Removing a plugin
    To remove a plugin `foo`:
    To remove `foo`:
    ```
    cd ~/.vim
    git submodule deinit pack/plugins/start/foo
    @@ -55,17 +55,17 @@ rm -r .git/modules/pack/plugins/start/foo
    ```
    ### Updating a plugin
    To update a plugin `foo`:
    To update `foo`:
    ```
    cd ~/.vim/pack/plugins/start/foo
    git pull origin master
    git pull
    ```
    It is recommended to first `git fetch origin master` a plugin, review changes, and then `git merge`.
    It is recommended to first `git fetch` a plugin, review changes, and then `git merge`.
    To update all the plugins:
    ```
    cd ~/.vim
    git submodule foreach git pull origin master
    git submodule foreach git pull
    ```
    Note that new commits to plugins create uncommitted changes in the main repository.
    @@ -75,5 +75,7 @@ cd ~/.vim
    git commit -am "Updated plugins."
    ```
    On another machine, if a `git pull` for the main repository leads to uncommitted changes in the submodules (as a few plugins got updated), perform `git submodule update` to change the state of the submodules.
    Even though slightly complicated, submodules are a necessary devil when you want to maintain an easily-cloneable `.vim` repository.
    The other option is to _not_ version-control submodules at all by adding a line `pack` in `~/.vim/.gitignore`, and manually add plugins on a new machine.
  5. @manasthakur manasthakur revised this gist Jan 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion submodules.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ git submodule add https://github.com/manasthakur/bar.git pack/plugins/start/bar
    git commit -m "Added submodules."
    ```

    ### Replicate the repository on a machine
    ### Replicating the repository on a machine
    - Clone the repository (_recursively_ to clone plugins as well):

    ```
  6. @manasthakur manasthakur revised this gist Jan 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion submodules.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Why submodules?
    # Using git-submodules to version-control Vim plugins
    If you work across many computers (and even otherwise!), it's a good idea to keep a copy of your setup on the cloud, preferably in a git repository, and clone it on another machine when you need.
    Thus, you should keep the `.vim` directory along with your `.vimrc` version-controlled.

  7. @manasthakur manasthakur revised this gist Jan 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion submodules.md
    Original file line number Diff line number Diff line change
    @@ -76,4 +76,4 @@ git commit -am "Updated plugins."
    ```
    Even though slightly complicated, submodules are a necessary devil when you want to maintain an easily-cloneable `.vim` repository.
    The other option is to not version-control submodules at all by adding `pack` inside `~/.vim/.gitignore`, and manually add plugins on a new machine.
    The other option is to _not_ version-control submodules at all by adding a line `pack` in `~/.vim/.gitignore`, and manually add plugins on a new machine.
  8. @manasthakur manasthakur revised this gist Jan 7, 2017. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions submodules.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    If you work across many computers (and even otherwise!), it's a good idea to keep a copy of your setup on the cloud, preferably in a git repository, and clone it on another machine when you need.
    Thus, you should keep the `.vim` directory along with your `.vimrc` version-controlled.

    But when you have plugins installed inside `.vim/bundle` (if you use [pathogen](https://github.com/tpope/vim-pathogen)) or inside `.vim/pack/plugins/start` (if you use Vim 8's packages), keeping a copy where you want to be able to update the plugins (individual git repositories), as well your configuration as a whole, requires you to use git submodules.
    But when you have plugins installed inside `.vim/bundle` (if you use [pathogen](https://github.com/tpope/vim-pathogen)) or inside `.vim/pack/plugins/start` (if you use Vim 8's packages), keeping a copy where you want to be able to update the plugins (individual git repositories), as well as your vim-configuration as a whole, requires you to use git submodules.

    ### Creating the repository
    Initialize a git repository inside your `.vim` directory, add everything (including the vimrc), commit and push to a GitHub/BitBucket/GitLab repository:
    @@ -51,7 +51,7 @@ To remove a plugin `foo`:
    cd ~/.vim
    git submodule deinit pack/plugins/start/foo
    git rm -r pack/plugins/start/foo
    rm -rf .git/modules/pack/plugins/start/foo
    rm -r .git/modules/pack/plugins/start/foo
    ```
    ### Updating a plugin
    @@ -68,11 +68,12 @@ cd ~/.vim
    git submodule foreach git pull origin master
    ```
    Note that the new commits to the plugins create uncommitted changes in the main repository.
    Note that new commits to plugins create uncommitted changes in the main repository.
    Thus, after any updates in the submodules, you need to commit the main repository as well:
    ```
    cd ~/.vim
    git commit -am "Updated plugins."
    ```
    Even though slightly complicated, submodules are a necessary devil when you want to maintain an easily-cloneable `.vim` repository.
    The other option is to not version-control submodules at all by adding `pack` inside `~/.vim/.gitignore`, and manually add plugins on a new machine.
  9. @manasthakur manasthakur created this gist Jan 7, 2017.
    78 changes: 78 additions & 0 deletions submodules.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    ## Why submodules?
    If you work across many computers (and even otherwise!), it's a good idea to keep a copy of your setup on the cloud, preferably in a git repository, and clone it on another machine when you need.
    Thus, you should keep the `.vim` directory along with your `.vimrc` version-controlled.

    But when you have plugins installed inside `.vim/bundle` (if you use [pathogen](https://github.com/tpope/vim-pathogen)) or inside `.vim/pack/plugins/start` (if you use Vim 8's packages), keeping a copy where you want to be able to update the plugins (individual git repositories), as well your configuration as a whole, requires you to use git submodules.

    ### Creating the repository
    Initialize a git repository inside your `.vim` directory, add everything (including the vimrc), commit and push to a GitHub/BitBucket/GitLab repository:
    ```
    cd ~/.vim
    cp ~/.vimrc vimrc
    git init
    git add *
    git commit -m "Initial commit."
    git remote add origin https://github.com/username/reponame.git
    git push -u origin master
    ```

    To enable submodules for plugins (say `foo` and `bar` located at `https://github.com/manasthakur/foo` and `https://github.com/manasthakur/bar` respectively) using Vim 8' packages:
    ```
    cd ~/.vim
    git submodule init
    git submodule add https://github.com/manasthakur/foo.git pack/plugins/start/foo
    git submodule add https://github.com/manasthakur/bar.git pack/plugins/start/bar
    git commit -m "Added submodules."
    ```

    ### Replicate the repository on a machine
    - Clone the repository (_recursively_ to clone plugins as well):

    ```
    git clone --recursive https://github.com/username/reponame.git
    ```
    - Symlink `.vim` and `.vimrc`:
    ```
    ln -sf reponame ~/.vim
    ln -sf reponame/vimrc ~/.vimrc
    ```
    - Generate helptags for plugins:
    ```
    vim
    :helptags ALL
    ```
    ### Removing a plugin
    To remove a plugin `foo`:
    ```
    cd ~/.vim
    git submodule deinit pack/plugins/start/foo
    git rm -r pack/plugins/start/foo
    rm -rf .git/modules/pack/plugins/start/foo
    ```
    ### Updating a plugin
    To update a plugin `foo`:
    ```
    cd ~/.vim/pack/plugins/start/foo
    git pull origin master
    ```
    It is recommended to first `git fetch origin master` a plugin, review changes, and then `git merge`.
    To update all the plugins:
    ```
    cd ~/.vim
    git submodule foreach git pull origin master
    ```
    Note that the new commits to the plugins create uncommitted changes in the main repository.
    Thus, after any updates in the submodules, you need to commit the main repository as well:
    ```
    cd ~/.vim
    git commit -am "Updated plugins."
    ```
    Even though slightly complicated, submodules are a necessary devil when you want to maintain an easily-cloneable `.vim` repository.