Iterate on config#

When making changes which will likely break the config temporarily, use git worktrees to keep both the current version and the in-flux version available for use.

This is also the default setup, where the config is cloned as a bare repo at ~/.config/neovim-config.git/bare.

git clone github:vvnraman/neovim-config.git --bare ~/.config/neovim-config.git/bare
cd ~/.config/neovim-config.git/bare
git worktree add ~/.config/nvim dev
git worktree add ~/.config/neovim-config.git/master master

The active branch is checked out at ~/.config/nvim, in this case the dev branch.

Making minimal changes#

During steady state, when no changes are happening, or minimal changes are being made.

cd ~/.config/nvim
git switch -c spring-clean

Major refactoring#

First make sure master is available as an alternate config, before doing any refactor.

  • Make sure no uncommitted changes are present in ~/.config/nvim

    cd ~/.config/nvim
    git status
    
  • Make sure master is checked out at ~/.config/neovim-config.git/master (add it if missing)

    cd ~/.config/neovim-config.git/bare
    git worktree list
    git worktree add ~/.config/neovim-config.git/master master
    
  • Make an mvim function (m for master branch)

    ~/.bashrc#
    function mvim {
      NVIM_APPNAME="neovim-config.git/master" /usr/bin/nvim "$@"
    }
    
  • Create a new worktree for the refactor branch and leave ~/.config/nvim (dev) untouched

    cd ~/.config/neovim-config.git/bare
    git worktree add -b holiday-update ~/.config/neovim-config.git/holiday-update dev
    
  • Do the refactor in ~/.config/neovim-config.git/holiday-update

  • Validate changes using Test in Docker

  • Fast-forward merge holiday-update into dev once satisfied

    cd ~/.config/nvim
    git status
    git merge-base --is-ancestor dev holiday-update
    git merge --ff-only holiday-update
    
  • Remove temporary refactor worktree and branch after merge

    cd ~/.config/neovim-config.git/bare
    git worktree remove ~/.config/neovim-config.git/holiday-update
    git branch -d holiday-update