Skip to content
This repository was archived by the owner on Sep 15, 2022. It is now read-only.

How to Work with branches

JoAnMontero edited this page Apr 7, 2015 · 2 revisions

First, we will see the necesary steps to develop in our own branch:

  1. We create our new branch with: git checkout -b newBranch The -b options will automaticly switch us to the new branch.

  2. We make some changes at some file.

  3. We add the changes to a commit as we ussualy do: git status git add filesToCommit git commit -m "Commit comentary"

  4. We push our commit to our branch. git push origin newBranch Alterlatively, we can use this instead: git push -u origin newBranch If 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:

  1. Switch to master, or to any branch we want to merge our changes to: git checkout master

  2. Merge our changes to our local copy of the destiny branch: git merge newBranch

  3. Now we push our changes to origin/master with: git push origin master

  4. If we dont need our branch anymore and there are not unmerged changes, we delete the branch with: git branch -d newBranch

Clone this wiki locally