I'm new to Git and this is really confusing. I wanted to start off developing a web application on Git and so far I've been dealing with troubles that have kept me behind.
I've read this blog post on a successful branching model for Git. I was really interested in setting up something similar to this.
It says that the repository has 2 main branches called master
and develop
. So I went ahead and created a repository. However, to my surprise, the repository itself was the default master
branch. How was I supposed to create a develop
branch? Do I create it in the parent of the master
branch? That would mean that the develop
branch is outside the repository.
Am I getting something totally wrong here? Do I just ignore the fact that I'm creating two branches inside the master 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.
Instead of a single main branch, this workflow uses two branches to record the history of the project. The main branch stores the official release history, and the develop branch serves as an integration branch for features. It's also convenient to tag all commits in the main branch with a version number.
Master branch is the main working branch created when you pushed your file for the first time into GIT repository. Develop or any other branch is typically created by Admin to restrict developers to make any changes in master branch. As doing this without proper review and testing will break the working of application.
A branch is not a directory. It is a commit label that moves along with commits, like tag is a commit label that stays with a particular commit. You will not have anything "inside" the master
branch, rather master
and develop
will both initially label the same commit.
Create the develop branch like so:
git branch develop
To clarify: let's say you have the initial commit A. It will be labeled as master
branch.
git init A [master]
If you make a new commit B, the branch label will move:
git commit -a A -> B [master]
If you then branch into develop
, the B will get the new label as well:
git branch develop A -> B [master, develop]
If you commit on the develop
, it will move, but master
won't:
git checkout develop git commit -a A -> B [master] -> C [develop]
If you now commit on the master
, the tree will fork:
git checkout master git commit -a A -> B -> C [develop] +--> D [master]
Meanwhile, you only have in your directory whatever the contents of your current commit is. Switch branches, and the directory contents change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With