Git Workflow Cheat Sheet Par :Corey Leung December 18, 2017 Updated January 19, 2018 Git allows developers to easily track project versions, see changes between old and new code files, segment projects into branches and more! A git workflow process is seen by many as essential for any project so we've developed a quick and dirty cheat sheet to help you get started. Start your git repository On your local machine: mkdir myproject: Creates a new directory to put all the files into for your project. Replace ‘myproject’ with a simple but descriptive name for your project. cd myproject: Change directory to your new project. git init: Initialize your new directory to be a git repository. touch README.md: Create an empty file in your directory named README.md. It is recommended to write up the description of your project here. git add README.md: Add this file into your git repository. Git will begin tracking changes to this file. git commit -m “Initial commit”: Commit the changes you have made to your repository in to git’s system, and add the comment that it is your initial commit. ALL commits require a message/comment. Github Actions Log into GitHub Click ‘New Repository’ On the next page, give your repository a unique name Leave it public and click on 'Create Repository' at the bottom On the next page, find the section for existing repositories and copy the two commands they give you to your clipboard In your Terminal, run the two commands from GitHub Connect Local to Remote On your local machine: git remote add origin <paste SSH Clone URL>: Register with your local git repository that you will be distributing all changes to a remote repository. git remote -v: Verify that your local git repository can speak/sync with the remote one. git push -u origin master: Push all changes to your master branch up to your remote repository. The-u flag means that git will use this remote/local combination when you type ‘git push’ going forward (until you specify a new combination). Make a Branch On your local machine: git checkout -b mynewbranch: This creates a new branch and switches to it in one command. Merging Branches On your local machine: git checkout master: Switch back to master branch git merge mynewbranch: Merge all of the differences between branch and master into the master branch. This brings all the work you have done in your branch in to the master branch git push origin master: Push all the changes you have made to your code by merging your branch to the remote repository.