Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I create git branch like develop/user1/issue1

I want a create git branch like develop/user1/issue1 on remote repository how can I create that?

- master => /origin/master
- develop => /origin/develop
    - user1 => /origin/develop/user1
         - issue1 => /origin/develop/user1/issue1
         - issue2 => /origin/develop/user1/issue2
         - issue3 => /origin/develop/user1/issue3
    - user2 => /origin/develop/user2
         - issue4 => /origin/develop/user1/issue4
         - issue5 => /origin/develop/user1/issue5
like image 865
Kyounghwan Kim Avatar asked Sep 12 '13 11:09

Kyounghwan Kim


1 Answers

Basically you can't create the structure as you are proposing.

Why?

Because when you have a branch with slashes in it, it gets stored as a directory hierarchy under .git/refs/heads

How to verify

Say you don't have any branches in an empty directory.

So you create a dummy repository using

touch testfile && git init && git add . && git commit -m "initializing"`.

Next, run the git branch command to create some branches as you suggested.

git branch origin/master
git branch origin/develop/user1
git branch origin/develop/user2/issue4

Now, cd into the .git/refs/heads directory using cd .git/refs/heads and do a ls -la

You will find that git has created the following directory structure.

master (file)
origin (directory)
|_master (file)
|_develop (directory)
   |_user1 (file)
   |_user2(directory)
     |_issue4 (file)

If now you try creating a branch using git branch origin/develop/user1/issue1, it will throw the error because a file named user1 already exists while your command needs it to be a directory.

like image 126
Anshul Goyal Avatar answered Oct 18 '22 00:10

Anshul Goyal