GIT &

GITHUB

Made by Vini

GIT & GITHUB
CHEAT SHEET

Essential Git and GitHub commands for professional developers.

GIT / Engine

Git is the technology. It is a version control software, which means it helps you manage and track changes in your files over time. When you're building a project, you constantly edit, delete, and add code. Git records those changes in “commits,” which are like saved checkpoints. If you make a mistake, you can go back to an earlier version of your project instead of starting over. You can download Git directly on your computer and it works locally, not requiring the internet. Git lets you create branches, which are separate versions of your project where you can test new ideas safely. Later, you can merge those changes back into your main project.

GITHUB / Vault

GitHub is the platform. It is an online platform that hosts Git repositories in the cloud. While Git works locally on your computer to track changes and manage versions of your code, GitHub allows you to store those Git projects online so you can access them from anywhere and collaborate with others. With GitHub, you can push your local Git commits to a remote repository, share your code, work with teammates, review changes, and manage projects. It adds collaboration features like pull requests, issue tracking, and project boards, but underneath it all, it uses Git to handle the version control.

Setup & Config

Global Identity

git config --global user.name "Vini"
git config --global user.email "vini@dev.com"
git config --list

New Repository

git init
git clone [url]

Daily Workflow

Saving Changes

git add .
git add [file]
git commit -m "feat: login"
git commit --amend

Monitoring

git status

Remote Sync

Synchronization

git push origin [branch]
git pull origin [branch]
git fetch

Remote Management

git remote add origin [url]
git remote -v

Branch Flow

Branching

git checkout -b feature-name
git switch [branch]
git branch
git branch -d [name]

Integration

git merge [branch]

Inspection

History

git log --oneline --graph
git log -n 5

Differences

git diff
git diff --staged

Recovery

Undo Commits

git reset --soft HEAD~1
git reset --hard HEAD
git checkout -- [file]

Stash

git stash
git stash pop