Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create development branch from master on GitHub

Tags:

git

github

I created a repo on GitHub and only have a master branch so far. My local working copy is completely up to date with the remote/origin master on GitHub.

I now want to create a development branch on GitHub so that other people on my team can start pushing changes to development (instead of directly to master) and submit PRs, request code reviews, etc.

So I tried creating a new development branch locally and pushing it:

git checkout -b development git push origin development:master 

But git just says Everything up-to-date. So I ask:

If I'm current with master, how do I just create a remote development branch that contains an exact copy of master?

like image 863
smeeb Avatar asked Sep 13 '16 20:09

smeeb


People also ask

How do I change a branch from master to develop?

The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.

What is the difference between master and develop branch?

master — this branch contains production code. All development code is merged into master in sometime. develop — this branch contains pre-production code. When the features are finished then they are merged into develop.

How do I create a new branch from a repository?

Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch. Simply use a git push origin command on subsequent pushes of the new branch to the remote repo.

What is develop branch in GitHub?

A develop branch is created from main. A release branch is created from develop. Feature branches are created from develop. When a feature is complete it is merged into the develop branch. When the release branch is done it is merged into develop and main.


1 Answers

When you do

$ git push origin development:master 

What's actually happening is git is taking <local>:<remote> and updating <remote> to whatever the <local> branch is.

Since you executed git checkout -b development from master, your local development has all the commits master does; hence it shows as everything is up to date.

You can just do

$ git checkout -b development $ git push origin development 

to push the new branch

like image 133
ddavison Avatar answered Sep 19 '22 08:09

ddavison