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 8494665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:21:44+00:00 2026-06-10T23:21:44+00:00

I know running git-diff and other tools can identify the changes in the repository,

  • 0

I know running git-diff and other tools can identify the changes in the repository, but when I do a partial commit, I need to pass only the committed files (rather than the entire set of files that are touched) to the pre-commit hook.

For example, I modified three files and commit only two, and I want the pre-commit hook to know the name of the two files.

git status --porcelain

M A.c 
M B.c
M C.h

then I execute:

git commit -m "two files only" A.c B.c

How can the pre-commit hook get hold of the list of the two files only?

  • 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-06-10T23:21:46+00:00Added an answer on June 10, 2026 at 11:21 pm

    The pre-commit is run at the beginning of the commit process… @Vince’s link is the one to look at. Once the hook is running, your script can use git diff --cached --name-only to get the names of the staged files within the pre-commit script. The command works even if the user had staged more for commit, but only requested to commit a subset of the files on the command line.

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

Sidebar

Related Questions

Assuming that I know there is a git-daemon running at git://git.mycompany.com , how can
I want to reproduce the pager behavior that git-diff uses but I don't know
I know in Jenkins you can avoid duplicate builds from running on top of
I need to know which stored procedures are running. It's not an option to
How can I know which stored procedure is running in SQL Server 2005. And
I need to know how many instances of my process are running on a
I need to know which iOS device is currently running app (saying more exactly
How can I know under which IIS version my web application is running in
I'm trying to get a git commit email hook running using Git on Windows.
I know there are plenty of ways to run git on my server, but

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.