DEV Community

Cover image for A printable, PDF - Git cheatsheet
tq-bit
tq-bit

Posted on • Updated on

A printable, PDF - Git cheatsheet

Hello guys,

instead of a new article, I'd like to share two printable cheatsheets with you.

I hope you'll find these useful.

Cheatsheet 1: Common Git commands for local development

The first cheatsheet shows a common development workflow when working on a development project. Among these are:

  • How to initialize a Git repository
  • How to add and remove files from the Git repos
  • How to manage code changes over several new features

Git cheatsheet one

Get the PDF from my Git repos: https://github.com/tq-bit/dev-cheatsheets/blob/main/q-bit_cheatsheets_git_and_github_I.pdf

Cheatsheet 2: Remote Git Servers

The second cheatsheet shows you a common, distributed development pattern and visualizes how several maintainers work on the same codebase.

It attempts to answer the questions about:

  • How does a pull request work?
  • How are local and remote repositories synchronized?
  • How to delete a remote branch?

Image description

Get the PDF from my Git repos: https://github.com/tq-bit/dev-cheatsheets/blob/main/q-bit_cheatsheets_git_and_github_IGit%20Cheatsheet_II.pdf

Update 19.03.2022: Add new layout for Cheatsheet I

Oldest comments (8)

Collapse
 
roneo profile image
Roneo.org • Edited

Great work!
At step 4.) the names 'stash' and 'stage' are used to speak about the same thing

Collapse
 
tqbit profile image
tq-bit

Hi Reneo,

thanks for pointing it out, I've corrected the same in the img & pdf.

Collapse
 
azlan_syed profile image
Azlan-Syed

cool

Collapse
 
tanishqsinghanand profile image
Tanishq Singh Anand

OP 🔥🔥

Collapse
 
kirankamath96 profile image
Kiran Kamath

In cheatsheet 2 , developer 1 and developer 1(local), does the local means a new branch?

Collapse
 
tqbit profile image
tq-bit

Hi Kiran.

  • The local repos is the clone of the remote one
  • The light-green dots are a local branch (feature that is not reflected on remote)
  • The dark-green is the main branch of dev 1
Collapse
 
kurtdegreeff profile image
Kurt De Greeff

Could you please explain what the difference is between Origin and Upstream?
It is also not clear to me what the colors of all the dots stand for.. Thanks

Collapse
 
tqbit profile image
tq-bit • Edited

Hi Kurt.

Origin and Upstream are naming conventions when working with remote repositories

It's common to push to origin and pull from upstream

  • Imagine you are dev 1
  • Then you would register your fork as the 'origin'
git add origin https://gitserver.com/dev_1/my_code
git commit -m 'my commit'
git push origin
Enter fullscreen mode Exit fullscreen mode
  • And you would register the owners repos as 'upstream' to pull down changes
git add upstream https://gitserver.com/owner/my_code 
git stash
git pull upstream
git stash pop
Enter fullscreen mode Exit fullscreen mode

Regarding the dots - each color represents a separate repos/branch combination

E.g. for the owner repos

  • Dot 1 (red): owner/my_code/master
  • Dot 2 (green): pull request from dev_1/my_code/feature to owner/my_code/master
  • Dit 3 (red): owner/my_code/master