Doubts about branchs structure and repositories

Asked

Viewed 102 times

4

I’m starting to study and use DVCS (versioning programs: GIT, Mercurial).

I tried to reassemble a folder structure using branches but the result was not as expected. I wanted to understand how the structure works.

What I did was this:

I opened a rep on the gitbucket:

xyp

You have the master branch, and I created 5 branches: B1, B2, 3b, B4 and B5

I downloaded it to my machine in a briefcase, made a clone, pasted a folder [B1] inside that folder, finished the branch with the same branch:

git checkout -b b1

Afterward:

git add *

To add new files to such branch, and then commit:

git commit -m "1 commit b1"

Then I pushed:

git push https://*******@bitbucket.org/*****/******.git

And I did so in the 5 cases imagining that there would be following structure in the branches as the folders:

             masters
b1  b2 b3  b4

Only when I looked at the branches in the gitbucket, the structure was all bent:

  • 1 commit B1 got 5 branches inside [B1 B2 B3 B4 B5]
  • the 2 commit B2 got 4 branches inside [B2 B3 B4 B5]
  • the 3 commit B3 got 3 branches in [ B3 B4 B5]

And so on and so forth. And the last stayed with one, only with himself

commit b5 (b5)

Because this strange structure didn’t agree with what I thought and structured?

  • If you want each branch to leave the master, before creating a new check where it is, as it will be created from where it, if you create from the master, would have to synchronize the master and then create the branch.

  • Entering the graphical mode in the branches tab gitbuckt and listing they appear this structure, isos that I found strange 1 commit B5 1 Branches inside them appears [B5] 1 commit B4 2 branches inside them appears [B4 B5] 1 commit B3 branches inside them appears [B3 B4 B5] 1 commit B2 4 branches inside them appears [B2 B3 B4 B5] 1 commit B1 5 branches inside them appears [B1 B2 B3 B4 B5] what I expected was how I idealized 1 commit B5 1 Branches [B5] 1 branches 1 commit B4 1 [B4] 1 commit B3 1 branches [B3] 1 commit B2 1 branches [B2] 1 commit B1 1 branches [B1]

1 answer

0

And I did so in the 5 cases imagining that there would be following structure in the branches as the folders:

Here’s the problem: what you did after this.

You probably did the following:

mkdir b1
git checkout -b b1
git add *
git commit -m "1 commit b1"
git push

After that, instead of going back to the branch master and create the next branch from it, you continued:

mkdir b2
git checkout -b b2

And so on, creating a structure like this, with a branch created from the last branch:

                                  .---05
                                 /
                            .---04
                           /
                      .---03
                     /
                .---02
               /
         .---01
        /
  00<--´

And not the way I’d like:

               .---05
              /
             .---04
            /
           .---03
          /
         .---02
        /
  00<--´---01

That would be done by creating all branches from the branch master. Therefore, it lacked, between the commands of push and mkdir, one:

git checkout master

Browser other questions tagged

You are not signed in. Login or sign up in order to post.