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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:31:26+00:00 2026-06-06T16:31:26+00:00

What is the best practice for pushing clean code to the main branch? This

  • 0

What is the best practice for pushing clean code to the main branch?

This is a best practice question about Mercurial, however the thoughts of other DVCS/git users would also be applicable. If there is a suitable website please point me to it.

How do large projects with lots of contributers keep the main development branch clean?

I pull a copy of the source from the central repository and then make a bunch of local changes using branches, tags, local merges of experimental code and commits until everything is tested and works.

Now I make the final commit and push my changes back up to the trunk – this will send the full history of my local changes to the central server.

This is conceptually fine, however that means that the supervisor who performs the final build gets to see all my experimental and buggy code working towards the final tested version.

Is there a best practice way to slim down my push so that it only contains clean code? Is it my reposonsibility to clean my code (with collapse or other extensions), or does the supervisor select the clean bits and copy them to a ‘final release’ repository?

your help is much appreciated,

Steve

=======================

Answer: I have accepted Tims answer below and the link he has given about github in particular [ github.com/git/git/blob/master/Documentation/SubmittingPatches ]. So yes – clean up your submission before pushing it to the central repository!

  • 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-06T16:31:27+00:00Added an answer on June 6, 2026 at 4:31 pm

    First and foremost, you need to talk to your supervisor about the expected workflow for your project. The following general advice should be good for most situations, but your project may have reasons to do things differently.

    In general, you should strive to make the published history of your repository as clean as possible. Cleanliness can be judged by:

    • Small, cohesive changesets
    • Clean up or refactoring should be committed separately from new features.
    • Each commit should pass test (to allow for tools such as bisect)

    In all DVCS, there is the concept of local vs. published history. In most workflows, a changeset is considered to be published once it has been pushed to a public repository that other people have cloned.

    There are two basic rules regarding editing the history of a repo:

    1. Once you have published a changeset, you should not modify history. This implies that it is important to only push changesets that are ready to be published. In Mercurial terms, do not hg push all your outgoing changes. Instead, use hg push -b <branch> or hg push -r <rev> to perform a targeted push of specific changes. See EditingHistory on the Mercurial wiki for more specific reasoning and advise.

    2. Before publishing changesets (i.e. while they are local), you are free to amend, rebase, collapse, etc. as needed to create a ‘clean’ history. In git, this is accomplished using git commit --amend or git rebase. Mercurial has extensions such as queues (mq), histedit and collapse.

    On most projects, developers are expected to clean up their own code prior to submitting it for review and or publishing it. This saves the reviewer/integrator from wasting time on messy work.

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

Sidebar

Related Questions

This is a beginner-best-practice question in perl. I'm new to this language. The question
I guess this is a best-practice question: We have a test server, a git
Best practice question about setting Mongo indexes. Mongoengine, the Python ORM wrapper, allows you
Short best practice question: If an object A is injected into another object B,
This is a security best practice and I'm wondering if I should even be
I was wondering if there was a plugin or best practice for pushing the
What is the best practice about HTML tags in internationalized strings. Is that OK
Is there a best practice for this? I was thinking either to Create a
Another best-practice question to those with experience: How many models do you put in
does anyone know of any web application stress testing best practice documents? I'm about

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.