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.
- How do I acquire a “cleansed” Git repository?
- Git - revert all commits of the merge after push
- I've cloned a git repository and want to access a branch off of the master branch
- Deploying a git branch together with its submodule from Github to Heroku
- Merges between two branches in two directions - any good reason or completely forbid?
- Is it OK to use a long non-ascii name for the user.name Git configuration?
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?
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.