Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge development branch with master

Tags:

git

git-merge

I have two branches namely master and development in a GitHub Repository. I am doing all my development in development branch as shown.

git branch development git add * git commit -m "My initial commit message" git push -u origin development 

Now I want to merge all the changes on the development branch into the master. My current approach is:

git checkout master  git merge development git push -u origin master  

Please let me know if the procedure I am following is correct.

like image 812
Pawan Avatar asked Jan 05 '13 04:01

Pawan


People also ask

How do I merge from dev branch to master?

Merge your "dev" branch into the "master". git checkout dev # switch to "dev" branch if you're not already. git merge master # optionally, this command is being used to resolve any conflicts if you pushed any changes to your "master" but "dev" doesn't have that commit.

Can you merge a branch of a branch to master?

Once the feature is complete, the branch can be merged back into the main code branch. First we run git checkout master to change the active branch back to the master branch. Then we run the command git merge new-branch to merge the new feature into the master branch.


1 Answers

I generally like to merge master into the development first so that if there are any conflicts, I can resolve in the development branch itself and my master remains clean.

(on branch development)$ git merge master (resolve any merge conflicts if there are any) git checkout master git merge development (there won't be any conflicts now) 

There isn't much of a difference in the two approaches, but I have noticed sometimes that I don't want to merge the branch into master yet, after merging them, or that there is still more work to be done before these can be merged, so I tend to leave master untouched until final stuff.

EDIT: From comments

If you want to keep track of who did the merge and when, you can use --no-ff flag while merging to do so. This is generally useful only when merging development into the master (last step), because you might need to merge master into development (first step) multiple times in your workflow, and creating a commit node for these might not be very useful.

git merge --no-ff development 
like image 157
Sailesh Avatar answered Dec 07 '22 23:12

Sailesh