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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:29:01+00:00 2026-05-18T10:29:01+00:00

I git the purpose of rebase. It makes sense to me. Basically i I

  • 0

I git the purpose of rebase. It makes sense to me. Basically i I have a feature branch I’m working on and I’m ready to put it into the master branch I would do a rebase to squash all of my commits into one clean one so that it’s easily integrated into master without all the messy history. Right?

Here’s what we’ve been doing.

  1. Create a feature branch
  2. Add a bunch of commits as we build the feature
  3. Periodically merge the master branch into the feature branch (in order to avoid a painful merge down the road)
  4. When everything is done, merge feature branch into master

The problem I’m seeing is that periodically merging master into the feature branch causes problems when rebasing because now I have a bunch of master branch checkins mixed in amongst my feature checkins.

What’s the right workflow here? Where do the following commads come into play:

  • git rebase -i Head^#
  • git rebase master
  • git merge master
  • git-rerere
  • git reset –hard HEAD^
  • 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-18T10:29:02+00:00Added an answer on May 18, 2026 at 10:29 am

    You should only merge to/from master once, at the end of life of the branch. The idea of a feature/topic branch is that it only contains changes relevant to the feature; you lose that when you merge in master repeatedly. (You can read what Junio Hamano, the git maintainer, says about branches.)

    You can do a “practice” merge, that you will throw away, and use git-rerere to have Git automatically record your merge resolutions, so that they can be re-used when you really are ready to merge. See http://www.kernel.org/pub/software/scm/git/docs/git-rerere.html for background and tutorial. This is really cool because it lets you do the work of the merge, without committing it anywhere explicitly, and then get that work back “magically” when you really are ready to create the merge. So, instead of one big painful merge at the end, you can do a bunch of smaller, hopefully simpler, intermediate “practice” merges along the way. Roughly speaking:

    # Enable rerere
    git config --global rerere.enabled 1
    # Start a feature branch
    git checkout -b feature
    # Hack hack hack
    git commit
    git commit
    # Practice merge
    git merge master
    # ...then throw the merge commit away, the work is saved by rerere
    git reset --hard HEAD^
    # Hack hack hack
    git commit
    # Really merge to master, reusing any saved work from rerere
    git checkout master
    git merge feature
    git branch -d feature
    

    See also http://progit.org/2010/03/08/rerere.html for another tutorial.

    You can also periodically rebase your topic branch on top of master and then just do a merge at the end.

    To deal with a situation like the one where you are currently in, with a topic branch (say named feature) that has a series of merges from main mixed with various in-progress commits, the easiest approach would be to do a squashed merge to produce a “merged” working tree and then create a new commit (or series of commits) on to main. For example:

    git checkout master
    git merge --squash feature
    git commit
    

    This will produce a single commit that represents the state of the tree at the head of feature, merged into master.

    Of course, you can also just do a regular merge to master for this change, leaving the messy history of feature present, and just work more cleanly in the future. e.g., simply

    git checkout master
    git merge feature
    

    and move on.

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

Sidebar

Related Questions

As I understand from http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html the rebased branch is 'moved' on to another one.
I have a git repository. I want to create a branch for release snapshots.
My git repository has ~2,000 commits. For educational purposes, I have been playing around
git status tells me that my branch and the one I started from on
git diff master..lab It will produce the diff between the tips of the two
I use git for a slightly unusual purpose--it stores my text as I write
Is there anyone using git in such a fashion? I would like to distribute
I don't fully understand the purpose of using Git or Github; I know it
I would like to create a backup of a git repository that I use
I have always assumed that the .git/branches directory is for legacy purposes and that

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.