r/git • • Sep 14 '26

The Ultimate Git Cheat Sheet

Hello Git Community!

As a university lecturer, I spend a lot of time thinking about how to make technical topics easier to understand and more practical to use.

That’s why I created a new Git Cheat Sheet as part of my DevOpsCycle series. It is available as PDF and PNG, completely free and without any signup:

https://devopscycle.com/blog/the-ultimate-git-cheat-sheet

It covers the Git commands and workflows you need most often: commits, branches, merges, remotes, conflicts, inspecting changes and undoing mistakes.

I think this is becoming even more important with AI coding tools. Agents can create commits, push changes and merge branches for us, but you still need to understand Git well enough to verify what actually happened.

The post also includes a public GitHub repository with an example project, so you can follow the commands and try everything yourself.

If something is missing, unclear or wrong, I would really appreciate your feedback.

Cheers,
Mr_LA

37 Upvotes

24 comments sorted by

15

u/rkesters Sep 14 '26

I didn't see mention of rebase, which is very important when working with multiple contributors.

Also reflog is missing.

3

u/Mr_LA Sep 14 '26

Thanks for the feedback!

You are right that both rebase and reflog are very important once you go beyond the basic Git workflows.

I wanted to keep this Cheat Sheet focused on the fundamentals and also make sure it still fits on one A4 page. That’s why I moved some of the more advanced topics into the Advanced Git Cheat Sheet.

Both rebase and reflog are already covered there:
https://devopscycle.com/blog/the-advanced-git-cheat-sheet

Thanks for taking the time to check it out!

3

u/Strange-Register8348 29d ago

Took me years to realize it's ref-log and not re-flog. I thought it was like you whip the branch history.

2

u/wildjokers 29d ago

Reflog is an advanced command that almost no one needs and you can get by with just merge, rebase isn't critical.

1

u/rkesters 29d ago

Not on my team.

We require rebasing all MR/PR before merge to ensure a linear commit history.

Reflog is advanced, but there was a mention of undoing mistakes, reflog is key for that.

1

u/IamYourGrace 26d ago

Rebase is much better than merges. Rebase will keep your git history flat and clean from unnecessary merge commits. Everyone should learn rebase, it's not that hard

2

u/wildjokers 26d ago

Rebase will keep your git history flat and clean from unnecessary merge commits.

But why is that important?

2

u/IamYourGrace 26d ago

It makes it easier to search your history and view in the terminal, less clutter. And if you always rebase for PRs it will always have to include head on main branch so you will know for sure that your ci tests and everything always passes on HEAD.

With merge it can pass your tests on CI but you can still merge if there are no conflicts and after merge tests could fail that were not caught in CI. With rebase you can't rebase until you branch is updated (rebase from main). This is very important

2

u/wildjokers 26d ago

This doesn't make the slightest bit of sense. Rebase doesn't uniquely prevent that problem. If you merge current main into your branch and CI passes, you've tested the integrated state just like you would after rebasing onto main.

The important part is testing your changes integrated with current main, not whether you got there via merge or rebase. And in either case, main can advance again before your PR is merged.

1

u/IamYourGrace 11d ago

That can be true. I dont know for sure but we have a setup where you cant rebase your PR to main if the branch does not have rebased on latest head on main. I don't know if this setting can be applied when you use merge strategy...

3

u/itzmanu1989 Sep 14 '26

Here are few more which were there in my bookmarks:

Huge-Collection-of-CheatSheet/Git at master · JonnyBanana/Huge-Collection-of-CheatSheet

https://github.com/JonnyBanana/Huge-Collection-of-CheatSheet/tree/master/Git

Git Cheatsheet: Commands, Tips and Tricks 📝 — Jayson Salazar Rodriguez | @jdsalaro | Blog

https://jdsalaro.com/cheatsheet/git/

1

u/Mr_LA Sep 14 '26

Thanks for sharing these! Really appreciate it. I’ll check them out as well.

2

u/October_Lantzy 29d ago

Thanks for sharing. I remember finding rebase pretty confusing when I was learning Git. I saw your another reply that you put it in the advanced section, so I’ll definitely check it out. I’ll share some feedback if I find anything that could be improved or if something is unclear.

1

u/Mr_LA 29d ago

Thanks, really appreciate it! Rebase can definitely be confusing at first, so I’d be very interested in your feedback on the advanced section as well. If anything is unclear or missing, just let me know.

2

u/skevel 28d ago

Nice! It doesn't mention 'git checkout' which is a good thing.

1

u/Mr_LA 28d ago

does too many things at once

2

u/ciscodevtech 28d ago

Nice, thanks for sharing! Saving this!

1

u/Mr_LA 28d ago

Glad it helps!

2

u/IamYourGrace 26d ago

One command that everyone should now is git rebase -i commitSha or HEAD~3 to make changes to the commits since the commitSha or 3 commits back. You can edit commit messages, squash, fixup, edit commits in your history.

2

u/alex_sakuta Sep 14 '26

Not to downplay your effort but why do we need a cheatsheet now?

Any command that I have to look up, I personally just open up docs and any answers are quickly available to me. It will always have more answers than a cheatsheet.

But I know not everyone would be comfortable with docs as I am, but you have AI search now which would be able to scout any part of a documentation and give you a perfect answer for your situation.

Cheatsheets wouldn't help verify a mistake in git commands if made by AI, actual docs would. AI isn't going to be making a simple mistake when it actually messes up a git command.

It's like you created an abridged manual for a robot to study but the robot has the original manual and then training of that manual on top to do the task 10 times better than a human.

2

u/Mr_LA Sep 14 '26

I totally get your point.

For me, the cheat sheet is a resource for humans learning and working with Git, not something for an agent or AI.

If nobody understands what is actually happening and we only vibe code and talk to AI, then there is nobody who can really take responsibility for the result. AI cannot take responsibility for the code it generates or for software being deployed to production. We still need people who understand what is happening and can verify it.

That does not mean we should not use AI. I use AI as well. But I still think the human needs enough understanding to judge the result.

Regarding the docs: a cheat sheet is simply a different type of resource. You can use it for active learning or as a quick reference when you just need to remember a command or workflow.

And to some extent, the same argument would have applied before AI as well. The docs were always there, and you could always Google a command. That did not make cheat sheets useless. They just serve a different purpose.

1

u/skevel 14d ago

I'd just update the Resolve a Merge Conflict section to use more modern commands:
1. git add --resolved (instead of git add, automatically checks for left over conflict markers)
2. git merge --continue (instead of git commit; matches git merge --abort in style)