Giter Site home page Giter Site logo

gitflow-example's Introduction

Gitflow Example

Motivation

A common branching strategy is important to ensure efficient collaboration, simplify release management and for traceability of changes.

Gitflow

https://nvie.com/posts/a-successful-git-branching-model/

GitFlow Overview

Branches:

  • master: represents production
  • develop: represents the integration branch. When implementing features/bugfixes we branch from it and merge back to it.
  • feature/xyz: Branch holding feature xyz. This is the branch you are going to do your feature on.
  • bugfix/xyz: Branch holding feature xyz. This is the branch you are going to do your feature on.
  • release/x.x.x: Branch for stabilizing release x.x.x
  • hotfix/x.x.x: Branch for hotfixes if we need to quickly fix something in production (Blocker issue)

Exercise:

  1. Check out the repository:
git clone https://github.com/peyerroger/gitflow-example.git gitflow-example2
  1. Make sure your local copy of the remote repository is up to date (since we checked it out like 1min ago, it will be the case. But it won't be in the future.)
git fetch
  1. Create a new feature branch from the develop branch. The command below will check out origin/develop (which is your local copy of it. Since we did git fetch, it is also the state of the branch in the remote repository) and create the local branch feature/xyz from it.
git checkout -b feature/xyz origin/develop
  1. Add your skills to your personal file /people/.md

  2. Add your changes to the staging area. The first command will only add exactly this file. If you want to add all changed file use the second command.

git add people/<your-name>.md
git add *
  1. Commit your changes
git commit -m "Updated skills of <your-name>"
  1. We are now ready to push our changes. But before we actually do this, we should make sure that our branch has all the changes from the remote. In case we got conflicts we need to resolve the first. (Note that git pull is a shortcut for git fetch and git merge)
git pull
  1. (Optional) Resolve conflicts and then execute the following commands:
git add *
git commit -m "Fixed conflicts"
  1. Push your feature to the repository.
git push origin refs/heads/feature/xyz:feature/xyz
  1. Create a Pull Request

Create PR

Select the target branch. In our case develop.

Create PR 2

  1. Review someone else's PR

Review PR

  1. Integrate your PR

Merge PR

  1. Clean up your feature branch

Clean up

Once you've checked out a new branch, delete your old feature branch. (You cannot delete your current branch)

git branch -d feature/xyz
  1. Fetch the latest changes locally.
git fetch
  1. (Roger only) Create a release branch
git checkout -b release/0.2.0 origin/develop
  1. (Roger only) Fix the bug
git add *
git commit -m "Fixing issue xyz"
  1. Push the release branch
git push origin refs/heads/release/0.2.0:release/0.2.0
  1. Bring back changes to develop by creating a PR release/0.2.0 -> develop.

  2. Create a PR release/0.2.0 -> master

  3. Tag the commit

  4. Deploy to production

gitflow-example's People

Contributors

aasche avatar ibarjasi94 avatar mesicbenjamin avatar peyerroger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.