what is good way to do merge the code in below sce

2019-08-25 11:06发布

问题:

Git merging code

Let us say I have a branch called origin/develop , Everytime I work on a new feature I create a new branch from origin/develop as feature/feature_name Let us say that I am working on the feature for a few days , I made some changes and also commited them to the remote feature/feature_name brach Now Let us say that the origin/develop itself was changed meanwhile becuase some other developers commiting to it through pull requests. If i create a pull request now to merge the code from feature/feature_name to origin/develop Stash does not like it.

I am using intellij idea to interact with Git , What is a clean way to get the changes that were made in origin/develop into my branch

Thanks

回答1:

Clean way to merge changes

Create a branch from develop

Checkout to develop branch

git checkout develop

get latest, as many developers pushed their code to develop

git pull

CreateBranch from develop

git checkout -b feature/test_feature

Push, worked for few days on the feature and push your changes to remote feature/test_feature branch

git push -u origin feature/test_feature

Merge changes from your branch to develop

We have two steps

STEP 1: Get latest from develop to feature/test_feature to test the your changes working with latest.

git checkout develop

git pull

git checkout feature/test_feature

git merge --no-ff origin develop

Note: conflicts may occur if the other developer modified the same file that you modified at the same line

STEP 2: Push your chnages from feature/test_feature to develop

git checkout develop

git merge --no-ff origin feature/test_feature

DONE



回答2:

Here are detailed instructions on how to apply changes from master to a feature branch in IntelliJ IDEA: https://www.jetbrains.com/help/idea/2017.3/using-git-integration.html#apply-changes