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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:46:15+00:00 2026-05-14T08:46:15+00:00

I just created a big piece of code I want to commit in several

  • 0

I just created a big piece of code I want to commit in several separate commits.
So I can stage relevant parts, commit, stage, commit, … and so on until I have all my changes commited.

The missing part is how can I test whether I split the commit correcty.
I.e. whether the part that is in staging area at least compiles?

To do that I must somehow bring my work tree to be in sync with index (staging area) without losing the changes to be committed later.

What is the right way to do it?
What is the quickest way to do it?

Update:
How to do it with magit?

  • 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-14T08:46:16+00:00Added an answer on May 14, 2026 at 8:46 am

    You could do it with:

    $ git branch task1 # first set of commit to do
    

    An intermediate branch can be useful to record some intermediate commits when you are slowly adding some content to the index.

    Then try an interactive session for adding just what you want:

    $ git add -i
    

    Add any time you want to check what you have added:

    $ git stash --keep-index
    

    If it compiles, git commit your current work, and if task1 is not yet complete, git stash pop to restore the full working tree and repeat.

    Once task1 is fully baked, you can trim all those ‘task1‘ commits, and merge the all work in master:

    $ git checkout master
    $ git merge task1
    $ git branch -D task1 # no need for that intermediate branch
    

    If you want to conserve the history of some significant task1 commits, you can rebase first task1 on top of master, before merging master in task1 (fast-forward)

    Finally, if your stash still contains some work in progress, repeat the all process for task2.

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

Sidebar

Related Questions

I just created a Database Application for Requesting Parts. It has several forms, one
Just created a WSS site with a some custom web-parts. But I get an
-- I just parsed a big file and I created a list containing 42.000
I created several ctree models (about 40 to 80) which I want evaluate rather
I want to mock a ResultSet. Seriously. I'm refactoring one big complicated piece of
Just created an acc on SO to ask this :) Assuming this simplified example:
I just created a ASP.NET MVC project and was able to build and browse
I just created a new table and filled it with data. When I run
I just created a user control. This control also makes use of my static
I just created a PHP page that spits outs some data from my database

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.