jstanley
jstanley

Reputation: 2097

How do you create a directory structure in Git?

I am trying to understand how to create a directory structure in Git that maps to my development process.

BTW, I am a newbie to Git, but not in source control.

I am using GitLab as my repository manager.

I have added my repository into GitLab and successfully cloned the repository.

The development process I want to create is as follows:

master | done | QA | INT

Whenever someone clones the repository, they will automatically see this branch structure and will work off the int branch.

I have tried running the commands thinking it would create the structure, but it does not appear so (maybe I am wrong).

git checkout -b Done master
git checkout -b QA Done
git checkout -b INT QA

git branch
  Done
* INT
  QA
  master

Anyway, I am assuming I am missing something simple (hopefully).

Does anyone have any insight as to how I can setup this simple branch hierarchy?

Thanks

Upvotes: 0

Views: 3436

Answers (2)

e.doroskevic
e.doroskevic

Reputation: 2167

The structure is already there. You've made your branches. Now, its up to collaborators to do some work. Below is a way how to set up a default branch, if it's different from master

To change the default branch in Gitlab:

  1. Click Settings in the left-hand bar
  2. Change the Default Branch to the desired branch
  3. Click Save Changes

Upvotes: 2

ElpieKay
ElpieKay

Reputation: 30888

You might have some misunderstanding about git branches.

After your commands are run, the commits and branches in git are like this: enter image description here

A<-B means A is a parent of B or based on A, we make some changes and commit them, so we get a new commit B. The blue dashed arrow means the branch points to a commit.

Now if we checkout master and make another commit E, the graph is like this: enter image description here

Then we checkout Done and make another commit F, the graph becomes: enter image description here

If we merge Done to master, via git checkout master;git merge Done, it is like: enter image description here

In Git, a branch ref is a variable that stores the value or ref that it points to. The value is not constant. Every commit records the sha1 of its parent commit(s). The root commit A has 0 parents. The merge commit G has 2 parents. The left commits have 1 parent. git log -1 <commit> --pretty=%P or git log -1 <commit> --pretty=raw can show the parent sha1.

Upvotes: 10

Related Questions