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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:12:10+00:00 2026-05-24T20:12:10+00:00

D:\code\gt>git init Initialized empty Git repository in D:/code/gt/.git/ D:\code\gt>echo Zero > a D:\code\gt>git add

  • 0
D:\code\gt>git init
Initialized empty Git repository in D:/code/gt/.git/

D:\code\gt>echo Zero > a

D:\code\gt>git add a

D:\code\gt>git commit -m a
[master (root-commit) 392580e] a
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a

D:\code\gt>echo One > a

D:\code\gt>git add a

D:\code\gt>git commit -m another
[master 271efba] another
 1 files changed, 1 insertions(+), 1 deletions(-)

D:\code\gt>echo Second > a

D:\code\gt>git add a

D:\code\gt>git commit -m "yet another"
[master 8d2041e] yet another
 1 files changed, 1 insertions(+), 1 deletions(-)

D:\code\gt>git status
# On branch master
nothing to commit (working directory clean)

D:\code\gt>git checkout  271ef a

D:\code\gt>git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   a
#

As you can see, I checkout the file in the state it had at the 2nd commit. However, I don’t understand why it’s already added to the index. Why isn’t git letting me do the add?

  • 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-24T20:12:11+00:00Added an answer on May 24, 2026 at 8:12 pm

    This is a point which isn’t entirely clear from the git checkout documentation, so it’s a good question.

    When you do:

    git checkout COMMIT -- PATH
    

    … the working copy and the index for PATH are updated with the version from COMMIT. So, relative to HEAD, there are indeed changes to that file staged after running that command.

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

Sidebar

Related Questions

In a Git code repository I want to list all commits that contain a
I've changed from Git to SVN the folders which contains the project's code, but
I'd like to check code committed to my remote git repository with PHP CodeSniffer
I sync my development code on 2 machines using a git bare repository on
I have an existing Git repository on Github. I wanted to reorganise my code,
I am using 'git' to checkout chromium code by following this document: http://code.google.com/p/chromium/wiki/UsingGit And
I code in vim. I use git; and love git grep. Does anyone have
I have inherited some code (from zip file) from a developer and git initialzed,
I have a git repo, and a revision code I want it to get
Can I embed the following bash shell code: for name in $(git diff --name-only

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.