Within my project I am performing some tasks in a branch (branch_A), which was branched from the main branch of the project (master). Now I need to create a new branch, born from branch_A (say branch_A_branch)
How can I create a new branch from another already created with commands?
When I work from master, I do the build with:
git checkout -b "rama_A"
Would it be correct to place myself in branch_A (in this case I am already with -b) and from there do the same step?
It would be:
git checkout rama_A
git checkout -b "rama_A_ramificación"
And one last thing, to later merge these two branches (branch_A and branch_A_branch), that is, save the changes from branch A to branch_A itself, how should I do it? I am right?
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 their personal branch based on various criteria (functionality, task, milestone...). In simple developments, Development is used as the main development branch and branches according to the criteria mentioned above. In your case your branch_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 Git bash make suregit branch
you are on the branch you want the new branch to inherit from.With this structure you could build functionality into your branch_A and branch_A_Branch and you can merge changes by persisting your branch (add -A, commit -m "", push) and pulling from the branch you want to merge into: From branch_A_branch
or use the command
git merge rama_A_ramificación
from your branch_A .The command
git branch <new-branch>
allows you to create a new branch branch.Once created, you can use
git checkout new_branch
to switch to that branch.The command
git checkout
accepts the argument-b
, which will create the new branch and switch to it instantly.The following command creates the branch
<new-branch>
based on<existing-branch>
and switches to<new-branch>
instantlygit checkout -b <new-branch> <existing-branch>