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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:30:42+00:00 2026-06-11T14:30:42+00:00

I used git add -p to split my code changes into multiple commits. However,

  • 0

I used git add -p to split my code changes into multiple commits. However, doing git commit after that commits all changes, including the unstaged ones. I looked at a few questions on SO, but could not find any obvious mistake. Could you please help me understand what I am doing wrong? Below are the commands I tried, and their outputs.

bash-3.2$ git diff test11.txt
diff --git a/test11.txt b/test11.txt
index f077274..e811cae 100644
--- a/test11.txt
+++ b/test11.txt
@@ -1,5 +1,5 @@
-Hello
-World
+hello
+world

-Blahblahblah
-blah
+blahblahblah
+Blah
bash-3.2$ git add -p test11.txt
diff --git a/test11.txt b/test11.txt
index f077274..e811cae 100644
--- a/test11.txt
+++ b/test11.txt
@@ -1,5 +1,5 @@
-Hello
-World
+hello
+world

-Blahblahblah
-blah
+blahblahblah
+Blah
Stage this hunk [y,n,q,a,d,/,s,e,?]? s
Split into 2 hunks.
@@ -1,3 +1,3 @@
-Hello
-World
+hello
+world

Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? y
@@ -3,3 +3,3 @@

-Blahblahblah
-blah
+blahblahblah
+Blah
Stage this hunk [y,n,q,a,d,/,K,g,e,?]? n

bash-3.2$ git status
# On branch test
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   test11.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:   test11.txt
bash-3.2$ git commit test11.txt
[test 1b85189] Test12
 1 files changed, 4 insertions(+), 4 deletions(-)
bash-3.2$ git status
# On branch test
nothing added to commit
  • 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-11T14:30:44+00:00Added an answer on June 11, 2026 at 2:30 pm

    Don’t specify the filename in the git commit command.

    By default, git commit with no other parameters commits the contents of the index (whatever you have staged via git add).

    If you specify a filename, however, (e.g. git commit <filename>), then Git actually bypasses the index entirely and commits the current state of the specified file(s) as they are in the working directory.


    Basically, either use git add or specify filenames with git commit, but don’t do both.

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

Sidebar

Related Questions

I used git to commit changes in my repository, followed these steps git add
Was trying to commit some changes. I used git add to add any new
I understand that Git can be used without a central repository. However, I am
I'm using git in a project with multiple branches used concurrently, that is: A
Up to now I used git to manage my latex-files. However git manages all
I have a git repository with two branches; one for code that's used for
I have just used git add -p to add a bunch of changes to
I have my branch on my GIT repository where I used to commit and
I know that Git tracks changes I make to my application, and holds on
For example, if you have ever used git, when you do a commit it

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.