Grayscale profile picture

Patrique Ouimet

Developer

Git Workflow

Wed, Apr 22, 2020 8:38 AM

Here's a basic git workflow I've come to appreciate.

There's a few assumptions made with this workflow:

  • There's 2 main branches: master and dev
  • Each feature is a new branch based off of dev branch

Here's what the commands look like

git checkout dev # switch to dev branch
git pull origin dev # pull latest changes from dev branch
git checkout -b feature-1 # create a new branch named feature-1 based off of dev

# make some changes

git commit -am "Added feature 1" # commit changes
git push origin feature-1 # push changes to remote

After all the changes have been made and the feature is ready, create a pull request.

Once the pull requests process is done, merge the feature branch (feature-1) to dev. Those commands would look similar to this:

git checkout dev # switch to dev branch
git merge feature-1 # merge the feature-1 branch into dev branch

To view a pull requests branch, do the following:

git checkout dev # switch to dev branch
git fetch origin # get all remote branches
git checkout feature-2 # where feature-2 is another pull requests branch you want to have a look at

Once the dev branch is ready for release merge it into master:

git checkout master # switch to master branch
git merge dev # merge the dev branch into master branch

That's it! You can imagine that when things get merged into dev branch you could trigger a build to run a variety of tests.