Sample Git Workflow

Sailboat, used in a post about Git Workflow.

Introduction

This post illustrates a sample Git workflow.

General Git Workflow Diagrams

Left: Sandra Winkler – Git Workflow.
Right: Molly Nemerever – Git Workflow

Clone

git clone <project_name>
git clone https://github.com/RIT-SWEN-261-04/team-project-2215-swen-261-04-2-the-reading-room

Pull

Always pull code first!

How to pull from main:

git pull <full-url>
git pull https://github.com/RIT-SWEN-261-04/team-project-2215-swen-261-04-2-the-reading-room

Branches

Create new branch:

git checkout -b <name-of-branch>
git checkout -b olivia-login-unit-tests

Push your new unedited branch to GitHub: 

git push origin <name-of-branch>
git push origin olivia-login-unit-tests

How to switch to a branch:

git checkout <name-of-branch>
git checkout olivia-login-unit-tests

If needed for some reason, you can switch to main branch:

git checkout main

Status

Check the status of changed files:

git status

Add

Add or “stage” file to be included in the next commit:

git add <changed-file-name>
git add olivia.txt

This is considered bad practice. However, you can add all of the changed files in the branch (two ways):

git add -A
git add .

Commit

Committing with a message:

git commit -m "<text>"
git commit -m "added contact information to olivia.txt"

Push

Add to your branches up main:

git push --set-upstream origin <name-of-branch>
git push --set-upstream origin olivia-login-unit-tests

How to check your branch against main branch:

git checkout main

Pull Requests

We have been doing them through GitHub’s user interface.

  1. https://github.com/
  2. Navigate to the project.
  3. Click branches (image 1)
  4. Click pull request (image 2)
Image 1: Click branches
Image 2: Click pull request

Notify and Pull

Notify group members about merge. Then, have everyone pull from main.

How to pull from main:

git pull <full-url>
git pull https://github.com/RIT-SWEN-261-04/team-project-2215-swen-261-04-2-the-reading-room

Pull main branch to your branch:

git pull origin main

Conclusion

If you found this workflow helpful, checkout my other articles for SWEN-261 and my offensive security cheatsheet for CSEC-202, Offensive Security Attack Phases and Frameworks.

Join 1,216 other subscribers
Portrait of Olivia Gallucci in garden, used in LNP article.

Written by Olivia Gallucci

Olivia is an honors student at the Rochester Institute of Technology. She writes about security, open source software, and professional development.