Today I released nit, which is my attempt to provide a small and simple wrapper around git that helps me (and you!) save typing and optimizes git workflows. So I can focus on stuff that really matters.
It’s All About Status!
I found it particularly annoying when I commit and add files with git since I usually copy+pasted the file names manually to
git commit which involves keyboard and mouse and so on and so on.
Here’s how nit does it.
I just call the blank nit command in my working directory.
# On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be.. # (use "git checkout -- <file>..." to discard cha.. # # modified: on_stage.rb [a] # modified: staged.rb [b] # # Untracked files: # (use "git add <file>..." to include in what will.. # # brandnew.rb [c] # new.rb [d]
This is a shortcut to
git status with some additional information: The status screen renders a file index for each file which can be used on the command-line.
Indexes per default are characters on the right-hand side of the filename.
# modified: on_stage.rb [a]
This can be configured, in case you prefer digits or want the index to prepend the filename.
Commiting And Adding Files.
Now, having those file indexes you naturally don’t need to provide the entire file name anymore. Just give nit the indexes.
$ nit commit a c
This will interpolate the indexes and run
git add on_stage.rb git add brandnew.rb git commit
Note that adding files is obsolete. With nit, you just commit files and it will add them automatically.
The following will do the same, using nit’s auto-expansion and index splitting.
$ nit co ac
Actually, you can use any git command via nit, it will just do the index interpolation.
$ nit diff ac
Often I find myself having +10 files modified and the
git status screen gets confusing. This happens especially when refactoring bigger chunks of code.
Mostly, I work on, say, 3-4 files at a time and want to incrementally commit changes in this “file group” while the rest of the modified or added files get in my way.
# On branch master # .. # # modified: on_stage.rb [a] # modified: staged.rb [b] # modified: lib/new.rb [c] # modified: TODO [d] # modified: CHANGES [e] # modified: lib/new/more.rb [f] # modified: lib/new/less.rb [g] # modified: test/new_test.rb [h]
I could use
git stash to hide the changes I’ve made to the other files. After 20 minutes, I will have forgotten the stash, my changes, and I lose parts of my refactoring. Sucks.
Nit allows you to ignore files. They are simply no longer considered in the nit status screen.
$ nit ignore abdeh
$ nit # On branch master # .. # # modified: lib/new.rb [a] # modified: lib/new/more.rb [b] # modified: lib/new/less.rb [c] # # Ignored files: 5
I found this really helpful as I really just see the files I am working on at that very moment. And – nit reminds me that there’s still other files invisible.
Pushing And Pulling.
And, once I’m happy I just do
This will find out the current branch and push to origin.
git push origin master
Works for both
I am aware of the fact that git comes with many of those functions. I just don’t want to remember all the internals, how to configure git, how to change my shell prompt, aliasing git commands, how to use `git commit -p` and so on.
Nit simply reflects many steps of my personal everyday workflow. It really helps me typing less whilst allowing me to keep my hands to the keyboard and away from the mouse and my pants.
No longer must I copy file names but use indexes!
The character indexing makes it super easy to look at the screen while typing.
Ignoring files helps me focusing on my current task, which can be a 5 minute refactoring, without the pain of stashing-and-forgetting.
From Here And On.
The next versions of nit will allow extending the tool with your own commands – either as gems or in a
.nit directory. Also, I have several other, breathtaking features planned.
If you want more, just let me know.
And now, give it a go.
gem install nit