How do you rebase the current branch's changes on top of changes being merged in?

Okay. If I’m on a branch (say working), and I want to merge in the changes from another branch (say master), then I run the command git-merge master while on the working branch, and the changes get merged in without rebasing the history at all. If I run git-rebase master, then the changes in master are rebased to be put on the top of my working branch. But what if I want to merge in the changes from master but rebase my changes in working to be on top? How do I do that? Can it be done?

I could run git-rebase working on my master branch to put my changes on top in the master branch, but I’d like to be able to do that in my working branch, and I have no idea how. The closest that I can think of doing is creating a new branch from master and then rebase working‘s changes on top of that, but then I’d have a new branch instead of altering the working branch.

  • How to “git push” to private repository with prompt for username and password?
  • How to go to previous commits in eclipse and egit
  • Git changes not showing in VS2013 Update 2
  • How to switch between the tags in Git
  • Why does Git insist that a file has been modified even after a `git checkout --`?
  • How to remove selected commit log entries from a Git repository while keeping their changes?
  • gitignore across all branches?
  • Git and Dropbox - local repo
  • branches on same line as master in network view
  • Forgot to create new branch. How to transfer changes to new branch
  • Compare only changes in a commit with current working dir
  • GitHub - Repository state at specified time
  • 3 Solutions collect form web for “How do you rebase the current branch's changes on top of changes being merged in?”

    You’ve got what rebase does backwards. git rebase master does what you’re asking for — takes the changes on the current branch (since its divergence from master) and replays them on top of master, then sets the head of the current branch to be the head of that new history. It doesn’t replay the changes from master on top of the current branch.

    Another way to look at it is to consider git rebase master as:

    Rebase the current branch on top of master

    Here , ‘master‘ is the upstream branch, and that explain why, during a rebase, ours and theirs are reversed.

    I’ve just done this moments ago in the following way:

    1. backup your current work in progress git checkout -b work-in-progress
    2. fetch latest changes git fetch origin/master
    3. discard any local changes git reset --hard origin/master
    4. replay latest changes from master git rebase origin/master
    5. replay your work in progress git rebase origin/work-in-progress
    6. sync your work in progress with latest master git rebase origin/master
    Git Baby is a git and github fan, let's start git clone.