Skip to content

Team Instructions

Netanel Draiman edited this page Apr 4, 2016 · 4 revisions

Team Instructions

I. Always work on a separate branch!!!

II. GitHub Guide

FAQ


Create new remote branch

  1. Create new local branch:
    git branch <branch name>
  2. Checkout to our new local branch:
    git checkout <branch name>
  3. Create a new remote branch and set local branch to track it:
    git push -u origin <branch name>
  4. You are now working on your own separate branch.
  • Step 1 and 2 can be combined into one using:
    git checkout -b <branch name>

Merge Branches

Assuming we want to merge branch B into branch A.

  1. Make sure you have the latest version of each branch - go into each branch and git pull
  2. Go to branch A: git checkout A
  3. Merge the branches: git merge B
  4. If you have conflicts - Resolve Them
  5. push the changes to your remote branch: git push

Resolving Conflicts

Open the conflicted file (specified in the git bash output) and follow the instructions below

Example of conflicted file

<html>
  <head>
<<<<<<< HEAD
    <link type="text/css" rel="stylesheet" media="all" href="style.css" />
=======
    <!-- no style -->
>>>>>>> master
  </head>
  <body>
    <h1>Hello,World!</h1>
  </body>
</html>
  1. The conflict is between the >>>>>>>>>> and <<<<<<<<< with each branch's name written near it.
  2. The ======== separates between the 2 conflicting versions of the code
  3. Decide which version of the code you want to keep by simply deleting the code you don't want. (along with the conflict symbols: >>>>>>>>>, <<<<<<<<< etc)
  4. Commit the changes you made (by resolving the conflict), for example: git commit -m "merged and resolved conflicts"
  5. You have now successfully resolved the conflicts and can push to the remote repo: git push