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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:40:34+00:00 2026-05-20T08:40:34+00:00

There is a small topic branch that I’d like to apply on top of

  • 0

There is a small topic branch that I’d like to apply on top of my main branch. I think the canonical way to do this is:

git merge topic-branch

But I’d like to have the commits applied one-by-one instead of generating a merge commit.

Naively running git rebase topic-branch obviously won’t work because it applies my master onto the topic branch, as if the topic branch was my upstream. So I tried this:

git rebase master topic-branch

And this does what I want, except that now I have a detached HEAD, and I need to fix the master branch to point to the HEAD (using branch -f). I could of course write a Bash function to do this automatically, but is there a "proper" way to pull in a topic branch without using merge?

  • 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-20T08:40:35+00:00Added an answer on May 20, 2026 at 8:40 am

    How about:

    git checkout topic-branch
    git rebase master
    git checkout master
    git merge topic-branch
    

    This solves the problem for a local branch. Solving for a tracking branch is left as an exercise.

    EDIT: I suppose I should explain what’s going on here. First you change to the topic branch; then you rebase the topic branch so that it is based on master. (Then, of course, you test that everything still works. You do have automatic tests, right?) Now that the topic branch is ahead of the master, you can change back to master and merge topic into master; no merge commit is necessary, since it’s a fast-forward.

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

Sidebar

Related Questions

Is there a way to split a huge xul file into small xul files
Hey there. I'm trying to write a small program that will read the four
Is there a way, without javascript, to load a small image for a background
Starting from branch master, to merge a topic branch one just says git merge
First of all, I know there are a lot of questions about this topic.
There are a few threads floating around on the topic, but I think my
I know this topic has been discussed before on Stack Overflow. But there are
I work with a small team that uses git for source code management. Recently,
I work with a small team that uses git for source code management. Recently,
There are many discussions on this topic already, but I am all about flogging

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.