Scenario: Have 2 git branches main and develop. From develop branch I created a new branch with the name test. Did some changes in the test branch and am ready to merge it into the main branch. But before merging I need to get other changes made by another user to develop the branch and keep mine. Only after it, I can merge the test to the main.
Precondition: 2 branches main and develop
Step 1: create new branch develop -> test
Step 2: add some code to test branch
Step 3: bring changes from develop -> test (Note: update and keep my changes in test)
Step 4: merge test -> main
How can I perform step 3.
CodePudding user response:
Two simple approaches here would be to either merge develop
into test
or rebase test
on develop
. The merge option:
# from test
git fetch origin
git merge origin/develop
The rebase option:
# from test, again
git fetch origin
git rebase origin/develop
Assuming that you have already done a fetch recently and you have the latest changes in develop
, you may merge/rebase directly on local develop
and drop the git fetch
steps above.
CodePudding user response:
There two approaches to do that, depending on how you want to build history tree. To distinguish git merge vs git rebase, I highly recommend you should read link and link