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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:00:10+00:00 2026-05-21T07:00:10+00:00

When I am in the git command line, it’s rather difficult to commit some

  • 0

When I am in the git command line, it’s rather difficult to commit some files and keep the rest for another commit. How do I make this easy?

  • 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-21T07:00:10+00:00Added an answer on May 21, 2026 at 7:00 am

    It is quite simple. You need to add the changes that you want to the index first:

    git add file1 file2
    

    then

    git commit
    

    if you removed a file, the add does that. Add means “add the change” even though it is a removal.

    If you want to add all changes:

    git add -A
    

    The -a parameter on commit says to add all changes of tracked files and commit them. So

    git commit -a
    

    will not commit a new file you created. You must explicitly add this.

    The -m parameter allows you to avoid opening the editor to edit your commit message and use what you put in following the -m option:

    git commit -m "Use this message and don't open the editor"
    

    Sometimes this is not a good idea. If you just tried a merge and had conflicts, git caches a very nice message for you once you resolve the conflicts and commit. So there a git commit is better.

    To selectively add files, use the patch modifier on git add:

    git add -p
    

    This will now prompt you about the files. This is quite powerful as you can also specify parts of files, or alternatively edit what you want to add to the index. A git commit will only add those.

    If you want some gui help that is not tortoisegit (avoid windows shell integration), use git gui.

    Here is a diagram explaining the index (or staged files):

    enter image description here

    (from http://progit.org/book/ch2-2.html)

    hope this helps.

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

Sidebar

Related Questions

With git on the command line, you see the result of your pre-commit hooks
In the command line, if I type git tag --contains {commit} to obtain a
After i commit and push to the remote repository from the command line: git
I recently switched to command-line git for my personal projects. I have used 3-way
I have read this thread when I got the the git: command not found
If you're using Git from the command line, is there a way to delete
Is there a git command to add differences within a range of line-numbers to
I have written a command-line tool that uses sub-commands much like Mercurial, Git, Subversion
I know how to do a git rebase from the command line, but how
I just ran git merge otherBranch and it output this error to the command

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.