threads / discuss / 44289

git branches & merge

Subject: git branches & merge

## tl;dr

3 messages between Oct 12, 2016 and Oct 13, 2016.

replies: 2people: 3as markdown or json

webmaster@peter-speer.de· Oct 12, 2016, 13:50 UTC · lore

Hi. I have created a release_x branch to work on a new release. The branch is based on master. Later I needed to create a hotfix_x branch to work on a hotfix. This branch is also based on master.

In the hotfix_x branch I needed to correct an IP address to communicate with. After doing so, I merged the hotfix_x branch with master again and made my deployment.

Now in the release_x branche the IP address is still the old one. I am afraid of committing and merging my release_x branch since I think that my newly defined IP address (now on master) will be overridden when merging. Am I right? If yes, what is the best way to solve this?

Thanks -fuz

Kevin Daudt· Oct 13, 2016, 15:49 UTC · re: Anatoly Borodin · lore

Re: git branches & merge

On Wed, Oct 12, 2016 at 04:43:07PM +0200, Anatoly Borodin wrote:
Show 7 quoted lines
> Hi,
> 
> 
> the IP will not be overwritten, you'll still have the new IP in
> master. Nothing to worry about :)
> 
> 

To expand on that, git does a so called 3-way merge. This means git will look for a common base commit, and compare changes from both sides to see which side actually made a change.

In your case, the base and the release branch both should show the old ip, and the master side would show the new IP. This tells git that master has changed, and not the release branch, and takes the master side of the change, resulting the new IP to show up.

Hope this helps, Kevin.

← back to recent threads