How to Work with branches - Arquisoft/Trivial2a GitHub Wiki
First, we will see the necesary steps to develop in our own branch:
-
We create our new branch with:
git checkout -b newBranchThe -b options will automaticly switch us to the new branch. -
We make some changes at some file.
-
We add the changes to a commit as we ussualy do:
git statusgit add filesToCommitgit commit -m "Commit comentary" -
We push our commit to our branch.
git push origin newBranchAlterlatively, we can use this instead:git push -u origin newBranchIf we use the -u option, from now on we will be able to switch to the branch and just do:git push
When we end our changes and we want to merge our branch to master we need to:
-
Switch to master, or to any branch we want to merge our changes to:
git checkout master -
Merge our changes to our local copy of the destiny branch:
git merge newBranch -
Now we push our changes to origin/master with:
git push origin master -
If we dont need our branch anymore and there are not unmerged changes, we delete the branch with:
git branch -d newBranch