Sitemap
Jeffrey Kern

Jeffrey Kern

Experienced tech leader, driving projects and teams with data-driven decisions. Dedicated to guiding and supporting new entrants in the field.

Git Cheatsheet

2 min readAug 6, 2023
Press enter or click to view image in full size
Photo by Roman Synkevych on Unsplash

git init: This command starts a new Git repository. Think of it as creating a new save file for your project.

git clone <repository-url>: This is like downloading a copy of someone else’s save file to your computer.

git remote add origin <repository-url>: This is like telling your game console where to find the online server so you can upload or download save files. Once set, you don't need to tell it again.

git status: This command is like asking, “What’s different in my project since the last save point?”

git add <file-name>or git add .: This is like selecting which changes you want to save. git add . selects all changes.

git commit -m “Your message here”: This creates a new save point with all the changes you selected using git add. The message should describe what changes you made.

git push origin <branch-name>: This is like uploading your save file so others can see or download it. The <branch-name> is the version of your project that you want to upload.

Get Jeffrey Kern’s stories in your inbox

Join Medium for free to get updates from this writer.

git pull origin <branch-name>: This is like downloading the latest version of the project from a specific branch.

git checkout -b <branch-name>: This creates a new ‘branch’ or version of your project. It’s like creating a new save file where you can try out changes without messing up your main project.

git checkout <branch-name>: This lets you switch between different branches or versions of your project.

git merge <branch-name>: This is like combining two different versions of your project into one. If you’ve made changes in a branch, you can use git merge to combine those changes into the main project.

git branch — show-current: This tells you which version (or branch) of your project you’re currently working on.

git diff: This shows you what changes you’ve made since the last save point.

git log: This is like a history book of all the save points (commits) you’ve made in your project.

git stash: This lets you temporarily set aside (or stash) changes that you aren’t ready to commit yet. It’s like creating a temporary save file.

git reset — hard <commit-id>: This lets you go back to a previous save point. The <commit-id> is a unique code that identifies each commit.

Have something you use often that isn’t part of this list, please comment or contact me so we can add it. Happy coding!

--

--

Jeffrey Kern
Jeffrey Kern

Written by Jeffrey Kern

Experienced tech leader, driving projects and teams with data-driven decisions. Dedicated to guiding and supporting new entrants in the field.