Ensure `git describe` gives latest tag

I recently ran the upgrade instructions and I ended up with the version
I was already on. This happened because `git describe` describes a
commit using the most recent tag reachable from it. Since I already had
a tag checked out, it was describing the tag I had already checked out.

Thankfully, `git describe` accepts an optional commit-ish, which it will
use instead of what we have currently checked out. Testing this in my
terminal now gives me the latest tag on origin, which is what I am
interested in when updating to the latest version.

  ~/.nvm ❯❯❯ git describe --abbrev=0 --tags
  v0.30.1
  ~/.nvm ❯❯❯ git describe --abbrev=0 --tags origin
  v0.31.3

I also added it to the manual install instructions for consistency and
extra safety.
Joe Lencioni 2016-07-28 09:03:26 -07:00
parent c08010f610
commit 17a3272b8a
1 changed files with 2 additions and 2 deletions

View File

@ -84,7 +84,7 @@ For manual install create a folder somewhere in your filesystem with the `nvm.sh
Or if you have `git` installed, then just clone it, and check out the latest version:
```sh
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags origin`
```
To activate nvm, you need to source it from your shell:
@ -106,7 +106,7 @@ export NVM_DIR="$HOME/.nvm"
For manual upgrade with `git`, change to the `$NVM_DIR`, pull down the latest changes, and check out the latest version:
```sh
cd "$NVM_DIR" && git fetch origin && git checkout `git describe --abbrev=0 --tags`
cd "$NVM_DIR" && git fetch origin && git checkout `git describe --abbrev=0 --tags origin`
```
After upgrading, don't forget to activate the new version: