Creating a new branch on a branch in Git

I would like to know if it's possible / good practice git branch -b "devfeature1"

if I'm already on a branch "dev"

.

In sourcetree I am having trouble rendering this as it seems like the branch is on the same branch. Am I doing it right?

Does it do what I want to do and just doesn't show how I picture it?

On the main device: git checkout -b "dev"

In dev: git checkout -b "feature1"

A visual example of what I want:

Branches visual representation

thank

+3


source to share


3 answers


Yes, this is a common practice. And since branches in Git are just pointers to commits, this won't create any internal mess or anything like that.

PS I also advise you to read about common Git Workflows . This is a common practice for using Git branches. You might consider sticking to one of these depending on your needs and team size.



The approach you're talking about is somewhat called "Gitflow workflow". It is described in the link above and I personally like it and stick with it whenever possible (even in personal projects where such a structure is not needed at all).

Here is a cheatsheet for Git Workflow that is much clearer than Atlasian's description in the link above. There are many other related materials on the Internet as well. The Gitflow workflow is popular today.

+4


source


This is a fairly common practice. I have worked for several companies where the master branch production

has a branch for test

, which has branch

for dev

, and then some devs disconnect for certain tickets, say issues 313

what when ready issue 313

merge in dev

, after approval dev

merges into test

, after approval test

merges into production

.

Check this google search git branch diagram

, you can see its general



https://www.google.com/search?q=git+branch+diagram&espv=2&biw=2133&bih=1172&tbm=isch&imgil=U-l6OCo-1fbXGM%253A%253B8axB_4nJuSOBuM%253Bhttp25%25% 25252F2013% 25252F07% 25252Fmds-xml4% 25252F & source = iu & pf = m & fir = U-l6OCo-1fbXGM% 253A% 252C8axB_4nJuSOBuM% 252C_ & usg = __ 34SFjfg-HlBeulNRlToa860biIU% 3D & dpr = 0.9 & ved = 0CDcQyjc & ei = 0cZlVZCoEoaRsAWakIDYDQ # imgrc = _

+2


source


This is probably good practice. There is even a name for it - Gitflow. You can read more about this here: https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

+2


source







All Articles