Git: getting changes from another branch

Git

Git Problem Overview


I have a project which uses git and I'd like to start a new branch to add a major new feature.

Under the main branch, I'll continue to add bug fixes and minor features. At regular intervals I'd like to pull the changes from the main branch into my "major new feature" branch. What's the best way to do this?

Eventually, I'll merge the "major new feature" branch into the main branch.

Git Solutions


Solution 1 - Git

git checkout featurebranch && git rebase master

As long as you haven't pushed yet, it is better to replay your changes on top of master.

See:

Solution 2 - Git

git checkout featurebranch && git merge master

You can do this as many times as you like; it won't affect master and you will be able to easily do it the other way around whenever you find out you are done with the feature branch.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFunLovinCoderView Question on Stackoverflow
Solution 1 - GitVonCView Answer on Stackoverflow
Solution 2 - GitDavid WinslowView Answer on Stackoverflow