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

  • SEARCH
  • Home
  • 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 8723291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:35:48+00:00 2026-06-13T07:35:48+00:00

I’m trying to learn git using the ‘Pro Git’ book by Scott Chacon. When

  • 0

I’m trying to learn git using the ‘Pro Git’ book by Scott Chacon. When explaining how to Stage modified files (page 18), i understand with git add the files are scheduled for commit and then commited with git commit. It mentions that a commit is done, only the changes that were added will be actually be commited, and if i change a file again, i’d have to add it againg before commit so that all changes are comitted. The text says:

It turns out that Git stages a file exactly as it is when you run the git add
command.If you commit now, the version of the file as it was when you last ran the git add
command is how it will go into the commit, not the version of the file as it looks in your working directory when you run git commit. If you modify a file after you run git add
, you have to run git add again to stage the latest version of the file.

However, i’m seeing a different behaviour when trying it myself:

$ git status              #start clean
#On branch master
nothing to commit (working directory clean)

$ echo "hello" >> README.TXT 
git-question> git add README.TXT #added change to README

$ git status 
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
# 
#   modified:   README.TXT
#

$ echo "good bye" >> README.TXT            #change README after adding
$ git status #now 'hello' is added to be committed but not 'good bye'
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   README.TXT
#
# 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:   README.TXT
#

$ git commit -m "only hello" README.TXT        #commit, i would expect just 'hello' gets commited
[master 86e65eb] only hello
 1 file changed, 2 insertions(+)

$ git status         #QUESTION: How come there's nothing to commit?!
# On branch master
nothing to commit (working directory clean)

So the question is: Shouldn’t git commit just commit the changes that were added with git add? And if so, why does it commit the second change even if i didn’t add it?

  • 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-13T07:35:49+00:00Added an answer on June 13, 2026 at 7:35 am

    git commit will commit what is currently in the index and therefore what you explicitly added.

    However, in your example, you are doing git commit README.TXT which will commit the files you specify, that is the current file README.TXT. Just do git commit -m "only hello" to commit the index.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:

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.