Table of Contents

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

🌸👋🏻 Join 9,500+ followers! Let’s take this to your inbox. You’ll receive occasional emails about whatever’s on my mind—offensive security, open source, academics, boats, software freedom, you get the idea.


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

Resources

  • Oh Shit, Git!
    • Oh Shit, Git! If you find git confusing, don’t worry! You’re not alone. People who’ve been using it every day for years still make mistakes and aren’t sure how to fix them.
    • Git is hard: screwing up is easy, and figuring out how to fix your mistakes is fucking impossible. Git documentation has this chicken and egg problem where you can’t search for how to get yourself out of a mess, unless you already know the name of the thing you need to know about in order to fix your problem.
  • Learn Git Branching
    • Interested in learning Git? Well you’ve come to the right place! “Learn Git Branching” is the most visual and interactive way to learn Git on the web; you’ll be challenged with exciting levels, given step-by-step demonstrations of powerful features, and maybe even have a bit of fun along the way.

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.

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.

Discover more from Olivia A. Gallucci

Subscribe now to keep reading and get access to the full archive.

Continue reading