0

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

mprad
  • 71
  • 1
  • 5
  • Intellij-idea has VCS plugin that you can use which will give you GUI with difference in the merge conflicts and gives you option to select your change or their changes – Samuel Robert Oct 18 '17 at 05:04

1 Answers1

0

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

Community
  • 1
  • 1
Jinna Balu
  • 6,747
  • 38
  • 47