Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging develop branch into master

Tags:

git

merge

I have a local repo with 2 branches master and develop.

  • in develop branch I have all my Drupal 8 core code
  • in my master branch I have 1 commit (Initial commit)

On my remote repo I have all my Drupal 8 core code in branch develop. How do I get this code in the remote master branch? How do I have to merge those repo's?

Update:

When I do git status I get:

On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    griffioenrotterdam.sublime-project
    griffioenrotterdam.sublime-workspace
    sites/

nothing added to commit but untracked files present (use "git add" to track)

What do I have to do?

Update 2:

When I do git checkout develop I get:

error: The following untracked working tree files would be overwritten by checkout:
    sites/default/default.services.yml
    sites/default/default.settings.php
Please move or remove them before you can switch branches.
Aborting

What do I have to do?

like image 278
meez Avatar asked Apr 12 '16 10:04

meez


People also ask

How can merge a branch to master?

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. Note: git merge merges the specified branch into the currently active branch. So we need to be on the branch that we are merging into.

How do I merge branches to master in GitHub?

In GitHub Desktop, click Current Branch. Click Choose a branch to merge into BRANCH. Click the branch you want to merge into the current branch, then click Merge BRANCH into BRANCH. Note: If there are merge conflicts, GitHub Desktop will warn you above the Merge BRANCH into BRANCH button.

Does merging master into branch change master?

git merge master will update your current branch with the changes from your local master branch, the state of which will be that of when you last pulled while on that branch.


3 Answers

Summary: you need to switch to your develop branch, pull the code from the remote repo, then merge it into master (locally) and push it back to remote repo (into master branch)

git checkout develop
git pull origin develop
git checkout master
git merge develop
git push origin master
like image 65
ItayB Avatar answered Oct 22 '22 00:10

ItayB


Merge locally develop into master and then push

git checkout master
git merge develop
git push
like image 7
Francesco Avatar answered Oct 22 '22 02:10

Francesco


First commit your changes to master

 git checkout develop
 git pull origin develop
 git checkout master
 git merge develop
 git push origin master
like image 1
Arun Prasad Avatar answered Oct 22 '22 02:10

Arun Prasad