Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6019029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:21:40+00:00 2026-05-23T03:21:40+00:00

Sometimes Git can be rather tedious if there are many similar filenames. For instance:

  • 0

Sometimes Git can be rather tedious if there are many similar filenames. For instance:

# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   FormRegion1.Designer.cs
#       modified:   FormRegion1.cs
#       modified:   FormRegion1.resx
#       modified:   OptionPage.Designer.cs
#       modified:   OptionPage.cs
#       modified:   OptionPage.resx
#
no changes added to commit (use "git add" and/or "git commit -a")

I’d much rather type git diff 1 instead of git diff FormRegion1.Designer.cs (even with tab-completion). Currently I’m doing something like this:

git diff $( ~/gitstatn 1 )

where ~/gitstatn contains:

git status -s | head -n$1 | tail -n1 | cut -c 4-

which is no better.

How can I type something like git add 3 or git diff 5 and mean git add FormRegion1.resx or git diff OptionPage.cs, respectively?

I’m using Cygwin on Windows.

.

Edit – As per adymitruk‘s suggestion, I’ve settled on aliasing gpick to a script:

#!/usr/bin/bash

if [ -z $1 ]; then
    echo 'no git command specified'
elif [ -z $2 ]; then
    git $1
else
    git $1 $( git ls-files -m | head -n$2 | tail -n1 )
fi

which is sufficient for my needs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:21:41+00:00Added an answer on May 23, 2026 at 3:21 am

    Use git ls-files instead. You won’t need cut. You will need to script. You could use the -p parameter for add, but I like your script. make the script accept the command you want:

    gpick diff 1
    gpick add 3
    

    You may want to do something for untracked files too.

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes a labeled break or continue can make code a lot more readable. OUTERLOOP:
Sometimes I get Oracle connection problems because I can't figure out which tnsnames.ora file
Sometimes when I'm editing page or control the .designer files stop being updated with
Sometimes IE6 will render the text of a <ul> list the same color as
Sometimes I need to quickly extract some arbitrary data from XML files to put
Sometimes I have to work on code that moves the computer clock forward. In
Sometimes my Oracle database on Windows gets hosed. How do I do a manual
Sometimes, in PL SQL you want to add a parameter to a Package, Function
Sometimes coloring a logfile or other gives a good overview when looking for stuff
Sometimes we deploy applications behind customer firewall and we need read only access to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.