Veezus Kreist

Ignoring machine-specific changes to .rvmrc

At Hashrocket, we use RVM to manage our rubies and gemsets on client projects. We typically specify the version of ruby that’s in production in our .rvmrc, like so:

rvm_gemset_create_on_use_flag=1
rvm 1.8.7-p249@vurl

However, sometimes a machine will have a problem with an installation of ruby, and so we’ll use a different version on that machine. Yeah, the correct solution is to fix the damn ruby, but we solved the problem today by flexing some little-used git fu… updating the index to ignore local changes to a file.

So, our `git status` shows us:

# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   .rvmrc
#
no changes added to commit (use "git add" and/or "git commit -a")

Now let’s instruct git to assume our .rvmrc is unchanged:

git update-index --assume-unchanged .rvmrc

And now our `git status` looks much better:

# On branch master
nothing to commit (working directory clean)

Prune your remotes

Lark and I were working on a project the other day and were nowhere near a commit at the end of the day. So we created a feature branch and pushed a WIP commit:

1
2
3
4
5
6
veez ~/code/some_app (master)$ git co -b client_edits_business
M        app/models/user.rb
M        spec/models/user_spec.rb
...
Switched to a new branch 'client_edits_business'
veez ~/code/some_app (client_edits_business)$ 

We finished up the feature the next day, and a week or so later Lark IMed me asking if there was anything on the branch that needed saving. I knew there wasn’t, so I deleted the remote branch:

1
2
3
4
5
6
7
8
9
10
11
veez ~/code/some_app (master)$ git branch -a
  client_edits_business
* master
  remotes/origin/client_edits_business
  remotes/origin/master
veez ~/code/some_app (master)$ git branch -d client_edits_business
Deleted branch client_edits_business (was 1fc95e5).
veez ~/code/some_app (master)$ git push origin :client_edits_business
To git@github.com:hashrocket/some_app.git
 - [deleted]         client_edits_business
veez ~/code/some_app (master)$ 

The next morning Lark asked me about the branch again, as it was still showing up in his tracked branches:

1
2
3
4
jon@mbp2:~/git_hashrocket/some_app$ git branch -a
* master
  remotes/origin/client_edits_business
  remotes/origin/master

The solution? Prune your remote:

1
2
3
4
jon@mbp2:~/git_hashrocket/some_app$ git remote prune origin
Pruning origin
URL: git@github.com:hashrocket/some_app.git
* [pruned] origin/client_edits_business