David Vander Elst David Vander Elst - 3 months ago 8
Git Question

No git trees, why?

I'm new with git and I don't understand one thing.

I create a repository and a master branch.

I made an initial commit with lot of files.

I created a branch "

development
".

And from
development
branch a new branch for a new project.

I made some commit, push.

But all my git history is flat. Why ?

Why I look at other repository there is path tree like this:

log graph

Why mine still flat?

When the pat tree start to show different branches?

Answer

Why mine still flat? When the pat tree start to show different branches?

It starts branching out in earnest when you are making concurrent commits on different branches.

Meaning you need to make commits both on master and dev and newbranch to see a tree.

If not, if you just had commits (even though they are in successive branches), the graph of commits remains flat.

git init .
git add and commit on master:

m--m--m (master)

Then create branch dev:

git checkout -b dev
# add and commit on dev

m--m--m--d--d--d (dev)

Finally, new branch:

m--m--m--d--d--d--b--b (newbranch)
      |        |
    (master) (dev) 

If you go back to master dev and makes new commits, then you start to see a tree:

git checkout master
# new commits

git checkout dev
# new commits

m--m--m--M--M (master)
       \
        d--d--d--D--D (dev)
               \
                b--bb (newbranch)

See it with commands like:

git log --graph --abbrev-commit --decorate --date=relative --all