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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:45:33+00:00 2026-05-22T14:45:33+00:00

I have a branch from master with three changes and want to rebase it

  • 0

I have a branch from master with three changes and want to rebase it back on to master. For example:

$git checkout master
$git branch dev && git checkout dev
$<do 3 commits>
$git checkout master
$git rebase dev -i

Normally -i would give me the 3 commits and allow me to squash. In this case however it is just “noop” and when the rebase completes I see the three commits moved over to master. I guess here though, as the ancestor had not diverged, a fast forward was possible and so this is what happened. But I want to squash the commits.

I tried using –no-ff but it does exactly the same as in my original case (noop + no squashing).

I tried also doing (while on the dev branch)

$git rebase -i HEAD~3
$git checkout master
$git rebase dev

But this is a pain really and I have to know how many commits to squash for the HEAD~X part.

Footnote:
The reason this is important to me is that it is this squashed changeset that will be reviewed in gerrit. If they are separate, it makes reviewing impossible.

  • 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-22T14:45:34+00:00Added an answer on May 22, 2026 at 2:45 pm

    I’m not quite sure why you’re doing some of the things in your question, e.g. don’t you really mean $git branch dev && git checkout dev before you do the commits? With your version you’re just creating them on master anyway. (Incidentally, if I’m right, you can do git checkout -b dev as a shortcut.)

    The reason you just get a noop is that git rebase tries to reapply all the commits in the current branch that aren’t in the branch that you supply as the <upstream> argument. So, when you do git rebase -i dev while on master, there are no commits in master that aren’t on dev. Essentially, you want to do it the other way round. I would do the following:

    git checkout dev
    git rebase -i master
    [... change to 'squash' all but the first of the actions ...]
    

    Then your dev branch will just have one squashed commit and you can merge that into master if you like.

    Alternatively, you could use git merge --squash:

    git checkout master
    git merge --squash dev
    git commit -m "The changes from dev squashed into one commit"
    

    Then master will have a single new commit, which represents the result of merging dev into master squashed into one commit, and that new commit will only have one parent, rather than being a merge commit.

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

Sidebar

Related Questions

I have a branch called experiment. git checkout master echo 'some changes' > a.txt
I'm using git. I have a branch, apifixes , that was branched from master
I have a git branch (called v4), that was made from master just yesterday.
Here's the situation: On a particular branch, some changes have been merged in from
My local tree has diverged from the master: $ git status # On branch
I have a branch named lemon. I wanted to pull changes into it from
I have a git repository and two branches master and st (branched from master
I cloned a git repository from GitHub, made some changes and some commits; I
In Git, is there a way to merge all changes from one branch into
I have to remove a branch from svn history for good. Normally I would

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.