# Using git-number to add Git files by reference number

DevFeed: [Using git-number to add Git files by reference number](<https://devfeed.tech/articles/git-number-to-the-command-line-rescue-25252.md>)

Original publisher: [Read original article](<https://kau.sh/blog/git-number/>)

Author: Kaushik Gopal

Published: 2020-02-19T07:00:00Z

Content type: tutorial

Language: en

Sources: [Kaushik Gopal's Site](<https://devfeed.tech/sources/kaushik-gopal-s-site.md>)

Topics: [Git](<https://devfeed.tech/topics/git.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Terminal](<https://devfeed.tech/topics/terminal.md>), [Homebrew](<https://devfeed.tech/topics/homebrew.md>), [Perl](<https://devfeed.tech/topics/perl.md>)

Tags: [command-line](<https://devfeed.tech/tags/command-line.md>), [commands](<https://devfeed.tech/tags/commands.md>), [git](<https://devfeed.tech/tags/git.md>), [installation](<https://devfeed.tech/tags/installation.md>), [perl](<https://devfeed.tech/tags/perl.md>), [ruby](<https://devfeed.tech/tags/ruby.md>)

## AI overview

This tutorial presents git-number, a command-line tool that assigns reference numbers to changed files so they can be selected individually or by range in Git commands. It covers installation with Homebrew, the tool's Perl implementation, and usage notes.

## Source excerpt

If you're a programmer these days, you probably spend a large part of your day in git. If you're a command line zealot like me, you realize the holy ways of using your Terminal app for everything and aren't seduced by fancy GUIs that only stand to dissuade you from pure unbridled productivity. With that in mind, one typically finds themselves in a position where they have a few files that have changed liked so: If I had to add 2 out of those 3 files,1 typing the commands start to get a little tedious: :> git add images/content/git-0.png :> git add images/content/git-1.png Sure, if you happen to use fish (one of the nicest shells out there) the autocompletion helps reduce the tediousness. But it still doesn't beat being able to add files just by a number! What if you were presented with a git status like this: and then simply added the files by their reference number, like so: :> g add 4 :> g add 5 Wouldn't that be better? I've been doing this for years and trust me, it is! You probably won't see the difference with just a few files, but if you had 10 images being commited, then being able to simply type a range makes it a breeze to commit a bunch of files! :> g add 4-10 Installation ## So, how do you achieve something similar? Install git-number and 💥: :> brew install git-number :> git-number -s For years, I used a bunch of hand wrangled ruby files, that would help me achieve something similar but I discovered @holygeek already went through the trouble of building a much more mature version of this in Perl. Now I'm just using that version (and have gladly deleted all those scripts I had to grudgingly maintain). Notes ## Remember to git-number first ### It's important to make sure you run git-number first before running your git add <numeral> commands. I've noticed that git-number gets a little confused and tends to try issue commands on the wrong files from previous runs, if you don't (yikes). You probably want to run git-number anyway to see the status of changed f