Promote Git branch to master

I have a git (and Github) repo with a master branch, a development branch and several feature branches. Each of the feature branches have been branched off development and subsequently merged into development.

I’d now like to “promote” development to master. I don’t want to merge these two branches because conflicts may arise. Essentially, development is “production ready” and I’d like for master to reflect the current state of development. How can I do this?

  • git workflow for merging using fast-forward commits
  • how to recover remote branch git?
  • Why is Windows Azure's Git Deploy regularly unable to access my repository?
  • Get all revisions of a file in git
  • git: how to show commits since “the last time it was 5AM”
  • Git: If I push a new branch to origin, how to make it tracking automatically
  • Can multiple pull requests be sent to pull github commits?
  • How Can I Resolve:“can not open 'git-upload-pack' ” error in eclipse?
  • How to sort output of shorthand git status?
  • How do I create a readable diff of two spreadsheets using git diff?
  • How do I force git to use LF instead of CR+LF under windows?
  • Is there a way to tell how far Jenkins has gotten in cloning a Git repo?
  • 2 Solutions collect form web for “Promote Git branch to master”

    In other words, develop is your new master. The easiest way to do that would be to simply push developer to master:

     git push origin origin/development:master

    This will work if development started from current master. If not, and you don’t want to keep the history of the master you can force the push:

    git push -f origin/development:master 

    The problem with the forced push might arise if there is other work (branches) forked from master. In such case the safest approach would be to do a technical merge as described in the answers to earlier mentioned thread.

    I think that is better to have a merge commit when declaring develop as ready for production, so that you can roll back.

    While this is perfectly doable with plain git commands, I have a script to do all the steps:

    In practice this is what a promote command does:

    git pull --ff-only         # check we are up to date on our branch
    git checkout master        # go the target branch
    git pull --ff-only         # check updates there too
    git merge develop --no-ff  # merge with a commit
    git push                   # push the merge
    git checkout develop       # back to develop
    Git Baby is a git and github fan, let's start git clone.