Git: Merging changes from one upstream branch into another

Let’s say we have two branches, “Development” and “Testing”, in the upstream repository.    Our developers push their changes to the Development branch.  Periodically during the development cycle, we’ll need to update our Testing branch to bring it in line with the Development branch.

Some of these commands are optional (and are marked as such) – they just make things easier, or demonstrate what’s going on.  Note that we never use the “merge” command, but turns out that “pull” uses merge behind the scenes.

The first thing you’ll need to do is to open a git/bash command line.  And did I mention we’re on Windows?

#SETUP: clone the branch Testing onto your local machine (in a directory called “pfsda-integration”)
git clone -b Testing my-project-testing
cd my-project-testing/

#SETUP: for convenience (so you won't have to enter your user name and password every time):
git config credential.helper wincred

#OPTIONAL: You'll see logs dating back to when you created the branch. type q to exit.
git log

#pull all changes present in the Development branch into your local copy of Integration.
git pull . origin/Development

#OPTIONAL: Now you'll see logs from today. type q to exit.
git log

#push local changes to current upstream branch (i.e. Testing)
git push

Leave a Reply

Your email address will not be published. Required fields are marked *