Version: Nov 18, 2025
Git - Maybe a cheat sheet
TLDR: Lets talk about Git commands for linux terminal and git ignore file.
I think like most people, we all end up using GUI applications (like SmartGit or Git-Fork) to do our git actions. In this blog post, I want to provide some stragiht forward commands to let you move on to the next thing in your jou Journey.
Also some nice to knows about the .gitignore file that beginners may like to know quickly.
Table of Contents
📄 Cheat Sheet
Check current status
git status
Check what branch you're on
git branch
Always pull the newest changes from origin (fast-forward only)
git pull --ff-only
If you prefer forcing your local branch to match origin:
git fetch origin
git reset --hard origin/main # Replace 'main' with your branch
Add all changes
git add .
Commit with a message
git commit -m "Your commit message here"
Push to origin
git push origin HEAD
Single Liner
Maybe for the future, single line deployment:
git pull --ff-only && git add . && git commit -m "update" && git push
Or, if you want the force-sync first:
git fetch origin && git reset --hard origin/main && git add . && git commit -m "update" && git push
📁 .gitignore
Ignore everything in a folder except one file
/folder/*
!/folder/keep-me.txt
Ignore everything and subfolders too
**/folder/*
Without the /* at the end, it'll ignore everything regardless if you ass to negate ignore with the !
General ignores
Lots of projects and sites usually give you a .gitignore ready to go to easily kick off your project, even by language type. Eg, starting a Rust project versus C# project, different things are ignored. How and where? When creating a project in GitHub, you'll see your repo being kicked off with a chance to select a pre-made gitignore file for you.
Anyways! Below is a taste just in case you don't run into this. This really serves beginners, but you beginner, I recommend heading to GitHub and start playing around with your first repo.