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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:09:25+00:00 2026-05-21T11:09:25+00:00

This question pertains not only to how to accomplish this task, but to whether

  • 0

This question pertains not only to how to accomplish this task, but to whether doing so is good or bad practice with Git.

Consider that locally I do most work on the main branch, but I have created a topical branch I will call feature_branch. In the process of working on feature_branch and switching back and forth to do other work on the main branch, it turns out that I have made more than one commit on feature_branch, but between each commit, I have done no push. My questions are:

  1. Would you consider this bad practice? Would it not be wiser to stick with one commit per branch per push? In what cases would it be good to have multiple commits on a branch before a push is made?

  2. How should I best accomplish bringing the multiple commits on feature_branch into the main branch for a push? Is it a nuisance to not worry about it and just do the push where multiple commits get pushed, or is it less annoying to somehow merge the commits into one and then push? Again, how to do this?

  • 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-21T11:09:26+00:00Added an answer on May 21, 2026 at 11:09 am

    For your first question, no, there’s nothing wrong with pushing multiple commits at once. Many times, you may want to break your work down into a few small, logical commits, but only push them up once you feel like the whole series is ready. Or you might be making several commits locally while disconnected, and you push them all once you’re connected again. There’s no reason to limit yourself to one commit per push.

    I generally find that it’s a good idea to keep each commit a single, logical, coherent change, that includes everything it needs to work (so, it does not leave your code in a broken state). If you have a two commits, but they would cause the code to be broken if you only applied the first one, it might be a good idea to squash the second commit into the first. But if you have two commits where each one makes a reasonable change, pushing them as separate commits is fine.

    If you do want to squash several commits together, you can use git rebase -i. If you’re on feature_branch, you would run git rebase -i main. This will open an editor window, with a bunch of commits listed prefixed by pick. You can change all but the first to squash, which will tell Git to keep all of those changes, but squash them into the first commit. After you’ve done that, check out main and merge in feature_branch:

    git checkout feature_branch
    git rebase -i main
    git checkout main
    git merge feature_branch
    

    Alternatively, if you just want to squash everything in feature_branch into main, you could just do the following:

    git checkout main
    git merge --squash feature_branch
    git commit
    

    Which one you choose is up to you. Generally, I wouldn’t worry about having multiple smaller commits, but sometimes you don’t want to bother with extra minor commits, so you just squash them into one.

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

Sidebar

Related Questions

This question is begging for a bunch of why are you doing this? responses.
This question may be a stupid question, but I'm really curious. After playing games
This question has been asked many times, but I tried every solution and none
This question is more out of curiosity than a real problem. Consider the following
Before you flag this as a duplicate, I've read the other question , and
This question is about a specific programming problem I am having - I want
This question is similar to this one: LINQ to SQL: GroupBy() and Max() to
This question is best described in code. I have a class called Vertex that
This question is related to this question. The following code compiles fine VC9 compiler
This question is slightly different from the kind of finding longest sequence or substring

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.