Create branch from another using commands (git)

2

Within my project I am doing some tasks in a branch (rama_A), which was branched from the main branch of the project (master). Now I need to create a new branch, which is born from the branch_A (let's branch_A_ramification)

How can I create a new branch from another already created with commands?

When I work from master, I create with:

git checkout -b "rama_A"

Would it be correct to place myself in rama_A (in this case I'm already with -b) and start from there doing the same step?

It would stay:

git checkout rama_A
git checkout -b "rama_A_ramificación"

And one last thing, to then merge those two branches (branch_A and branch_A_ramification), that is, save the changes from the branch of A to the branch_A itself, how should I do it? Am I right?

    
asked by Norak 29.12.2017 в 09:48
source

1 answer

2

Your deduction is correct. The usual procedure with Git is to have two main branches (Master and Development) and usually one branch per developer (for development teams), and each developer would branch his personal branch according to several criteria (functionality, task, milestone ...). In simple developments Development is used as the main branch of development and branches according to the criteria mentioned above. In your case your rama_A would be Development or the development branch, so it would be correct to use git checkout -b rama_A_ramificación . If you use the Git bash, make sure with git branch that you are in the branch from which you want the new branch to inherit.

With this structure you could develop functionalities in your rama_A and in your rama_A_Ramificación and you can merge the changes persisting your branching (add -A, commit -m "", push) and pull from the branch you want to merge: From rama_A_ramificación

git add -A
git commit -m "New functionality"
git push origin rama_A_ramificacion
git checkout rama_A
git pull origin rama_A_ramificacion

or use the git merge rama_A_ramificación command from your rama_A .

    
answered by 29.12.2017 / 11:59
source