5

Here's what I am trying to do::

I have one project in one git repository. I've made some changes in master and created a spinoff branch (b s) called my-feature. Now I've finished my feature and would like to check it in. For checkin, I need to (fast-forward) merge my feature branch onto master and check in master. Normally I could do this with the awesome magit-merge-into (m i) feature). However by the time I am ready to push, master has changed, and I need to sync master with origin/master first before I merge my feature branch.

What is the best way to do this with Magit?


I'm guessing this is a common workflow for other developers as well. From the terminal I can do something like this from my feature branch to accomplish the above:

# On branch my-feature git checkout master git pull --rebase git checkout - # My feature branch git rebase - # master # Verify changes git checkout - # master git merge - # my-feature git push # pushes master git branch -d my-feature 

1 Answer 1

10

There's no need to checkout a local copy of master. You just need to fetch the current ref for the remote origin/master branch (assuming the appropriate remote is named origin), and then use that.

git checkout my-feature git fetch origin git rebase origin/master 

Assuming that origin/master is set as the upstream branch for my-feature then in magit this would be:

  • bb my-feature
  • fu
  • ru

If you need to configure a upstream remote in magit:

  • bu origin/master

Or alternatively you can use the "rebase elsewhere" option:

  • re origin/master

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.