[git] 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.

This question is related to git merge rebase git-rebase

The answer is


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.


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to merge

Pandas Merging 101 Python: pandas merge multiple dataframes Git merge with force overwrite Merge two dataframes by index Visual Studio Code how to resolve merge conflicts with git? merge one local branch into another local branch Merging dataframes on index with pandas Git merge is not possible because I have unmerged files Git merge develop into feature branch outputs "Already up-to-date" while it's not How merge two objects array in angularjs?

Examples related to rebase

Git refusing to merge unrelated histories on rebase Git push rejected "non-fast-forward" What's the difference between 'git merge' and 'git rebase'? How can I combine two commits into one commit? Remove folder and its contents from git/GitHub's history git cherry-pick says "...38c74d is a merge but no -m option was given" What does 'git remote add upstream' help achieve? How to get "their" changes in the middle of conflicting Git rebase? Git: How to rebase to a specific commit? How do you rebase the current branch's changes on top of changes being merged in?

Examples related to git-rebase

rebase in progress. Cannot commit. How to proceed or stop (abort)? git remove merge commit from history Choose Git merge strategy for specific files ("ours", "mine", "theirs") What's the difference between 'git merge' and 'git rebase'? Your branch is ahead of 'origin/master' by 3 commits Rebase feature branch onto another feature branch git rebase merge conflict Remove folder and its contents from git/GitHub's history How to get "their" changes in the middle of conflicting Git rebase? How to rebase local branch onto remote master