Skip to content

GitFlow Quickstart

Matthew edited this page May 13, 2021 · 10 revisions

GitFlow

Gitflow is a workflow that helps developers collaborate a seamless software development experience.

  • In this quickstart, we will be borrowing from Gitflow but not following it completely
  • If you are interested in the finer details, you can read about Gitflow here.

Our Git workflow

  1. Create a local branch that identifies you as the developer (e.g. mrodriguez)
  2. Push the local branch to track a remote branch on the server/origin
  3. Write code
  4. Stage changes of code you want to commit
  5. Commit the code to your local branch
  6. Push the changes
  7. Create a pull request

CLI

  • git branch <branch>
    • where <branch> is the branch name of your choosing
    • this will automatically checkout (switch you to) your new branch
  • git push -u origin <remote-branch>
    • where <remote-branch> is the branch name on the server
    • good practice to choose the same name as your local branch name
  • git push -u origin <remote-branch>
  • git add <file> to stage files for commit a commit
  • git commit -m "<commit message>" to commit staged files
  • git push to push local branch to remote branch

GitHub Desktop

Creating a Pull Request

A pull request is a way for your changes to be merged into the trunk. It provides opportunity for review and feedback, thereby protecting the trunk from unreviewed code.

  • If you pushed code to a remote branch the main page of the tamarisk repository should prompt you to create a pull request
  • When you create a pull request make sure to select marod424/tamarisk as the base Base Repository, the branch to merge into as the base: trunk, and the base to compare as your personal branch compare: <your-remote-branch>.
  • You can find all pull requests under the repo Pull requests tab
  • Pull requests will be reviewed by another collaborator and then merged in if accepted

Keeping your local branch up to date

It is best practice to keep your local branch up to date. This means that you should regularly pull the latest code from the trunk into your local branch.

  1. Checkout the trunk
  2. Pull the latest code from the remote trunk
  3. Checkout your local personal branch that you want to keep up to date
  4. Merge the trunk into your local branch

CLI

  • git checkout trunk
  • git pull
  • git checkout <branch> where <branch> is the name of your personal branch
  • git merge trunk (merges your trunk into your branch)

GitHub Desktop

Handling merge conflicts

Sometimes another developer is worker on the same file as you. If you try to merge changes that conflict with current work, you may need to manually resolve those conflicts.

  • In this scenario you should have a conversation with the other developer in which you conflict if you are unsure whose changes should be committed
  • Often you will need some combination of both your changes
  • The process to resolve conflicts isn't always trivial, and is best done through GitHub or the GitHub desktop merge conflicts flow.
  • Resolving a merge conflict on GitHub

Clone this wiki locally