Krishneil
Krishneil

Reputation: 1490

Merge in Master from a earlier Branch excluding all the changes in between

I am a git noob.

My current master branch is 2.1.18. Business requested me to create a new branch from the production version and apply changes and push to production. So I created a branch from the production version which was at 2. 1.10. Made changes and created a pull request Now a get the error

Conflicts prevent automatic merging 

How do I merge my current branch which I created from 2.1.10 into master which is 2.1.18 and exclude all the changes from 2.1.10(only include my current changes)- until 2.1.18?

Upvotes: 1

Views: 46

Answers (1)

VonC
VonC

Reputation: 1324347

Business requested me to create a new branch from the production version and apply changes and push to production

If you create a branch from 2.1.10 and not 2.1.18, that means what is running in production is 2.1.10.

So your pull request should not be made against master, since it is for pushing to production.

That being said, if you need to report your fix against the latest of master, I would:

  • leave your existing branch as is (it represents what has been pushed to production)
  • create another branch where your current fix branch is
  • rebase that new branch against master (and resolve any merge conflict in the context of that rebased branch)
  • make a PR from that rebased branch: no conflict there.

That is:

git checkout myFixBranchFrom2.1.10
git checkout -b myFixBranch
git rebase master

Upvotes: 2

Related Questions