Git merge commits from a specific upstream release

Scenario: I’ve forked a github project and begun working on it (after adding the original project as a remote called ‘upstream’). While working on my fork, a number of releases are made to the upstream project: v1.3-stable, v1.4-stable, v1.5-experimental, etc. Now I need to merge in the upstream commits to my master branch, but ONLY up to a specific release, for example, release v1.4-stable. What’s the best workflow for this scenario?

  • Starting git-daemon on OS X using launchd
  • Wont Let Me Type In My Pass Phrase
  • Implementing TFS Pull Requests
  • git-p4 submit fails with 'Path is not under client's root' error
  • git enter password before push/pull
  • How visualice multiples repos and clone them (git instaweb, gitlist, gitlab)
  • How can I make Jenkins CI with git trigger on pushes to master?
  • Git create a new branch with only a specified directory and its history then push to new repository
  • MissingObjectException while update submodules with JGit
  • No branches in SourceTree?
  • NetBeans not showing GIT in the right-click menu
  • Git: What does squash do? and Why cherry-pick an older commit?
  • 4 Solutions collect form web for “Git merge commits from a specific upstream release”

    Assuming v1.4-stable is a tag on the remote, you can apply those changes to your local repo by calling this from the branch that contains your work:

    git fetch
    git rebase --onto $(git rev-list -n1 v1.4-stable)

    Rev-list finds the ID of the latest commit from v1.4-stable, after which those commits are replayed and your own work placed neatly on top. There will be conflicts if the remote has changed significantly since you forked.

    If v1.4-stable is a branch on the remote you will instead want to do

    git pull --rebase origin v1.4-stable

    This assumes that v1.4-stable is a a tag for a commit indicating the release, on the master branch.
    Checkout master and pull the latest changes:

    git checkout master
    git pull --rebase

    Next, rebase your development branch on top of this commit. Make sure your working tree is clean and your HEAD is pointing to your dev-branch:

    git rebase v.14-stable

    This command will change the base of your branch to include the v.1.4-stable tagged commit, and all other releases preceding it.

    Before rebase:

    o---o---v.1.2---v.1.3---v.1.4---v.1.5-exp  master
          o---o---o  dev


    o---o---v.1.2---v.1.3---v.1.4---v.1.5-exp  master
                                o---o---o  dev

    First make sure you are working in a dedicated branch for v1.5-experimental.

    Second, reset your master branch to upstream/v1.4 (make sure you don’t have any work in progress: an hard reset would wipe them out)

    git fetch upstream
    git checkout master
    git reset --hard upstream/v1.4
    git push -f

    Finally, rebase your v1.5-exprimental branch on top of master (that is on top of v1.4)

    Fist, activate rerere (in case you have to do multiple rebase later on: that will record how you resolve similar conflicts in the past)

    git config --global rerere.enabled true

    Then rebase (replay your commit from your branch on top of v1.4):

    git checkout v1.5-experimental
    git rebase master
    git push -f

    The conflicts you will have to resolve there should only be conflicts of interest (concurrent modifications done both in upstream and in your experimental branch).

    git pull --rebase origin v1.4-stable
    Git Baby is a git and github fan, let's start git clone.