Git Workflows

Our Git Workflows #

Setting up git on your system #

Linux #

For Fedora (or RPM-based distributions) #

RUN

sudo dnf install git-all

For Debian-based distributions (such as Ubuntu) #

RUN:

sudo apt-get install git-all

MacOS #

If brew is already installed on your machine skip to Install git

Install brew #

RUN

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install git #

RUN

brew update
brew install git
brew install git-gui

Windows #

Install Git #

  • Download the office installer by going here
    • if link is broken google “git install windows”
  • Choose either the 32-bit or 64-bit install
  • After downloading, click yes to confirm changes
  • Click Next > choose a folder for the location of Git
  • Leave all checkboxes clicked by default > Click Next
  • Click Next
  • Choose a default text editor you want to use > Click Next
  • Let Git Decide > Click Next
  • Leave the default options and Click Next three times
  • For Configuring the line ending conversions
    • Choose Checkout Windows-style, commit Unix-style line endings
    • If there are any issues later down the road with committing, go to Working with multiple terminals
  • Click Next till the end and then click Install
  • After installing, you can View release notes and/or Launch Git Bash

To verify Git install go to command prompt

RUN

git

Working with multiple terminals #

  • According to this article, CRLF and LF endings are unnecessary due to modern editors handling of LF files.

Go to your VSCode GitBash terminal

RUN

git config --global core.autocrlf false
  • this will set autocrlf to false in your ~/.gitconfig
  • you can check that it updated the file by doing cat ~/.gitconfig

Get familiar with git #

Git is the number one version control system in the world by usage. However, some of the git concepts and commands might not come naturally. With practice, the git commands will become second nature to you. Get started with git by reading the offical docs on git here

Our branching strategy #

Mermaid testing #

gitGraph commit commit branch develop commit

Using branches #

  • Name your branches based on what you worked on and checkout using git checkout -b <name_of_branch>
  • Once checked out verify what branch you are located on using git branch
  • Delete a branch using git branch -d <name_of_branch>

How to commit changes #

  • Switch to a new terminal
  • Display your status using git status
  • Record the current state of the working directory with git stash
  • Checkout a new branch using git checkout -b <name_of_branch>
  • Verify you checked out the correct new branch using git branch
    • you will see that an * is next to the current branch you are working on
  • Pop your current state of the working directory using git stash pop
  • Stage the current changes to the working directory using git add <path_to_directory>
  • Commmit your changes using git commit
    • the command will open a text editor and you can add your commit message above the #
  • Finally, push your changes using git push --set-upstream origin <name_of_branch>
    • Delete the branch once you have merged