Andrew Connell
Andrew Connell

Reputation: 5287

Merge changes from an external git repo into my local branch

I asked a similar question here recently, but this is a more specific question.

I've cloned a open source project locally (OrchardCMS) & created a local branch (accom.dev) off a tag "1.6" in the origin/master branch in order to add my own tweaks to the codebase.

They have since made a lot of changes to the codebase, moving from 1.6 to 1.7 onto 1.7.1 and have even more commits (the current release is 1.7.1). What I want to do is take everything from the 1.7.1 tag (including everything that goes back to 1.6) and merge it into my local branch. From there I will address conflicts, fix my customizations and then deploy to my website.

Note this is NOT a cherry-pick as I want everything from 1.6 up to 1.7.1 merged into my local branch, BUT I don't want the stuff that has been committed SINCE the 1.7.1 release. IOW, I want my customizations to be based off the official 1.7.1 release, not on more recent stuff.

I'm pretty sure what I did gives me what I want, but I'm not sure if there was a better way:

  1. Switched back to to the origin/master
  2. Created a new local branch 1.7.1-release from the point where the 1.7.1 tag was created... this is treated as a temp branch because I couldn't figure out how to do a merge from a specific point
  3. Switched back to my accom.dev branch
  4. Merged the 1.7.1-release branch into my accom.dev branch
  5. Addressed conflicts & committed the changes in accom.dev
  6. Deleted the 1.7.1-release branch

At this point I am where I want to be, but I'm wondering if there was an easier way...

Upvotes: 0

Views: 104

Answers (1)

GoZoner
GoZoner

Reputation: 70135

An easier way is as follows (assumes origin is the name of your remote and that you have already checked out your accom.dev branch):

$ git fetch --tags origin
From ...
* [new tag]    some-tag -> some-tag
* [new tag]     ...

$ git merge some-tag

Upvotes: 1

Related Questions