How to switch to master, when there is no master

I have built a website with git and from the beginning I have done no work in the master branch, which is now empty. I started out with:

$ git checkout -b dev_project

and have done all my development in that branch. I thought it would be good to use the master branch as a release branch, but I can see that locally I don’t have that branch.

c:/wamp/www>git branch
8.0.x. (my drupal branch)
dev_project (my project branch)

So how can I merge dev_project HEAD into master?

  • an empty .git/info/sparse-checkout is not the same as a missing one, but the opposite, why?
  • Can I view instant results after a git push?
  • How to generate javadoc directly from Git
  • push from bitbucket repository to shared hosting ftp server
  • Python 3 Wont run from the Git Bash command line
  • How do I “reopen” a git commit?
  • Git ignores change to core.autocrlf
  • git merge files into working copy
  • 2 Solutions collect form web for “How to switch to master, when there is no master”

    Create the branch master:

    git branch master dev_project
    

    You don’t have anything to merge. Master will actually diverge from dev_project. That seems weird but it’s actually what you want to do.

    Continue working on dev_project, and when you want to release merge it into master, issuing:

    git checkout master
    git merge dev_project
    

    A branch is nothing more or less than a pointer to a commit in git. Since you have not created a master branch yet, there simply is no such pointer as there is nothing it could point to.
    You can start your release branch by simply calling

    git branch master
    

    This creates the pointer and points it to the current commit. After that, you can just keep working on your feature branches, and merge with master as you please.

    However, I would suggest using tags to mark releases: A branch is a dynamic entity by design, and from the commit history there is nothing that connects a given commit to any branch (it’s the branch that references the commit, not the other way round). As such, if you only use your master branch to publish versions, you won’t be able to find earlier versions again. The tag, by contrast, is a fixed entity, which is meant to be used to mark releases.

    Git Baby is a git and github fan, let's start git clone.