Skip to content

Instantly share code, notes, and snippets.

@robin-a-meade
Created June 24, 2026 06:19
Show Gist options
  • Select an option

  • Save robin-a-meade/d378e4c55ffa8b580f8995d29aff98f7 to your computer and use it in GitHub Desktop.

Select an option

Save robin-a-meade/d378e4c55ffa8b580f8995d29aff98f7 to your computer and use it in GitHub Desktop.
Update nvm

Update nvm

Official manual upgrade instructions
https://github.com/nvm-sh/nvm#manual-upgrade

(
  cd "$NVM_DIR"
  git fetch --tags origin
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"

Slightly simplified:

(
  cd "$NVM_DIR"
  git fetch --tags origin
  git checkout "$(git describe "$(git rev-list --tags="v[0-9]*" --max-count=1)")"
) && \. "$NVM_DIR/nvm.sh"

Simplifications:

  1. Move the pattern check to the rev-list command: --tags="v[0-9]*"
  2. Remove --tags from the describe command because we already restricted the lookup to being a tag
  3. Remove --abbrev=0 from the describe command because it serves no purpose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment