How does a Git repository works with a develop and master branch?

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.

  • Git tag before or after merge?
  • GIT hook post-receive and remote repository git pull
  • Fatal error unpacking a tree object during a git svn fetch
  • automated code formatting git
  • How can I indicate the Git username and password in Capistrano's deploy.rb?
  • Get files modified/added/removed from a commit in LibGit2Sharp
  • 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?

  • Is it possible to skip the staging area and (also) commit untracked, new files to git?
  • Why cherry-pick pick change more than one commit?
  • Fail to use git pull “Couldn't find remote ref xxx”
  • git difftool, open all diff files immediately, not in serial
  • Cloning a git-svn repository with svn metadata
  • Temporarily switch working copy to a specific Git commit
  • 2 Solutions collect form web for “How does a Git repository works with a develop and master branch?”

    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.

    The master branch is created by default; you can think of it like the “trunk” in other VCS systems. The develop branch used in the nvie branching model branches from master, presumably from the first commit.

    The develop branch is a normal branch off of master.

    git branch develop creates the develop branch.

    In the nvie branching model, all development work is done on the develop branch and only merged to master and tagged there when the code is ready to be released. The typical workflow that many people use is just to commit all development to master and tag when the code is ready to be released.

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