Quantcast
Channel: How do I safely merge a Git branch into master? - Stack Overflow
Viewing all articles
Browse latest Browse all 35

How do I safely merge a Git branch into master?

$
0
0

A new branch from master is created, we call it test.

There are several developers who either commit to master or create other branches and later merge into master.

Let's say work on test is taking several days and you want to continuously keep test updated with commits inside master.

I would do git pull origin master from test.

Question 1: Is this the right approach? Other developers could have easily worked on same files as I have worked btw.


My work on test is done and I am ready to merge it back to master. Here are the two ways I can think of:

A:

git checkout testgit pull origin mastergit push origin testgit checkout mastergit pull origin test 

B:

git checkout testgit pull origin mastergit checkout mastergit merge test

I am not using --rebase because from my understanding, rebase will get the changes from master and stack mine on top of that hence it could overwrite changes other people made.

Question 2: Which one of these two methods is right? What is the difference there?

The goal in all of this is to keep my test branch updated with the things happening in master and later I could merge them back into master hoping to keep the timeline as linear as possible.


Viewing all articles
Browse latest Browse all 35

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>