# Can we make interactive add easier to use?

3 messages from 2016-10-14 to 2016-10-16. Participants: Robert Dailey, Matthieu Moy, Jeff King.
Thread: https://gitlist.dev/t/44298

## Robert Dailey, 2016-10-14 13:20

Subject: Can we make interactive add easier to use?
Message-ID: <CAHd499AnuVximRgM0MKdq5JC-hwkrhox6bK_KA+XGrawoz2W+g@mail.gmail.com>
URL: https://gitlist.dev/e/CAHd499AnuVximRgM0MKdq5JC-hwkrhox6bK_KA%2BXGrawoz2W%2Bg%40mail.gmail.com

```
Normally when I use interactive add, I just want to add files to the
index via simple numbers, instead of typing paths. So I'll do this as
quick as I can:

1. Type `git add -i`
2. Press `u` after prompt appears
3. Press numbers for the files I want to add, ENTER key
4. ENTER key again to go back to main add -i menu
5. Press `q` to exit interactive add
6. Type `git commit`

This feels very tedious. Is there a simplified workflow for this? I
remember using a "git index" unofficial extension to git that let you
do a `git status` that showed numbers next to each item (including
untracked files!) and you could do `git add 1, 2, 3-5`, etc.

Thoughts? Even though this feels like I'm complaining, honestly I am
just consulting the experts here to see if I'm missing out on some
usability features. Thanks in advance!!

```

## Matthieu Moy, 2016-10-14 13:46

Subject: Re: Can we make interactive add easier to use?
Message-ID: <vpqfunz2gc9.fsf@anie.imag.fr>
URL: https://gitlist.dev/e/vpqfunz2gc9.fsf%40anie.imag.fr
In-Reply-To: <CAHd499AnuVximRgM0MKdq5JC-hwkrhox6bK_KA+XGrawoz2W+g@mail.gmail.com>

```
Robert Dailey <rcdailey.lists@gmail.com> writes:

> Normally when I use interactive add, I just want to add files to the
> index via simple numbers, instead of typing paths. So I'll do this as
> quick as I can:
>
> 1. Type `git add -i`
> 2. Press `u` after prompt appears
> 3. Press numbers for the files I want to add, ENTER key
> 4. ENTER key again to go back to main add -i menu
> 5. Press `q` to exit interactive add
> 6. Type `git commit`
>
> This feels very tedious. Is there a simplified workflow for this?

My workflow is to ... not use "git add -i" ;-).

To add patch hunks individually, "git add -p" jumps directly to the
"patch" inner loop of "git add -i".

To add whole individual files, a plain "git add" using zsh's smart
completion (autocompletes only files for which "git add" is not a
no-op), or globs.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Jeff King, 2016-10-14 19:12

Subject: Re: Can we make interactive add easier to use?
Message-ID: <20161014191254.stzzffyxk6ih3cwx@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20161014191254.stzzffyxk6ih3cwx%40sigill.intra.peff.net
In-Reply-To: <CAHd499AnuVximRgM0MKdq5JC-hwkrhox6bK_KA+XGrawoz2W+g@mail.gmail.com>

```
On Fri, Oct 14, 2016 at 08:20:40AM -0500, Robert Dailey wrote:

> Normally when I use interactive add, I just want to add files to the
> index via simple numbers, instead of typing paths. So I'll do this as
> quick as I can:

I'd generally second Matthieu's suggestion to use a combination of "git
add" and "git add -p". But if you really like the interactive updater,
then the optimizations I can think of are:

> 1. Type `git add -i`
> 2. Press `u` after prompt appears
> 3. Press numbers for the files I want to add, ENTER key
> 4. ENTER key again to go back to main add -i menu
> 5. Press `q` to exit interactive add
> 6. Type `git commit`

We have "git add -p" to avoid having to do a similar workflow just to
get to the "p"atch menu. So in theory we could have a similar shortcut
to get to "u"pdate. I think it's just not in common enough use that
anybody really bothered to implement it.

We also have "commit -p" (and "commit -i") already, though I do not use
them myself.

That would probably take you down to:

  1. git commit --iu ;# obviously a terrible option name
  2. Press numbers, then ENTER
  3. 'q' or ENTER or ^D to exit, and jump into commit message
     automatically.

You can also set the interactive.singleKey config option to turn (2)
into just "press numbers" (which works right now).

> This feels very tedious. Is there a simplified workflow for this? I
> remember using a "git index" unofficial extension to git that let you
> do a `git status` that showed numbers next to each item (including
> untracked files!) and you could do `git add 1, 2, 3-5`, etc.

TBH, that extension sounds a lot more generically useful, as it works at
the shell level. I _think_ I've seen similar features implemented that
are not even git specific (i.e., they work off of existing
shell-completion libraries and just let you pick the options by number
rather than tab-completing). Sorry I don't have any links, though. It's
not something I ever used myself.

-Peff

```
