Welcome to the Minimalist Git Cheat Sheet, where less is more and simplicity is key! Here, we’ve decluttered the most essential Git commands, leaving you with a clean, easy-to-navigate resource. Let’s embrace the joy of minimalism and create a clutter-free coding experience.

Table of Contents πŸ“š

  1. Setup
  2. Repositories
  3. Branches
  4. Commits
  5. Staging & Unstaging
  6. Merging & Rebasing
  7. Remote Repos
  8. Deleting & Resetting

1. Setup 🌱

Configure user info

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Purpose: Set your global Git identity, simplifying your future commits.

2. Repositories πŸ“

Initiate a fresh start

git init

Purpose: Create a clutter-free Git repository in the current directory.

Clone the essentials

git clone <repository-url>

Purpose: Copy an existing remote repository to your local workspace.

3. Branches 🌳

Display branch inventory

git branch

Purpose: List all local branches, keeping track of your minimal workspace.

Branch out

git checkout -b <new-branch-name>

Purpose: Embrace change by creating and switching to a new branch.

Switch to simplicity

git checkout <existing-branch-name>

Purpose: Redirect your focus to another branch.

Prune branches

git branch -d <branch-name>

Purpose: Declutter your workspace by removing unnecessary branches.

4. Commits ✍️

Commit to simplicity

git commit -m "Concise commit message"

Purpose: Capture the essence of your changes in a succinct commit.

Undo with elegance

git revert <commit-hash>

Purpose: Gracefully create a new commit that undoes a previous one.

Refine the past

git commit --amend -m "Improved commit message"

Purpose: Amend your last commit with a touch of minimalism.

Chronicle your journey

git log

Purpose: Reflect on your repository’s history with a clean log.

5. Staging & Unstaging πŸ“¦

Assess your progress

git status

Purpose: Gain clarity on the status of your working directory.

Stage with intention

git add <file-or-directory>

Purpose: Mindfully stage changes for your next commit.

Unstage with ease

git restore --staged <file-or-directory>

Purpose: Let go of previously staged changes that no longer serve you.

6. Merging & Rebasing 🧩

Merge mindfully

git merge <source-branch>

Purpose: Integrate changes from one branch into another with intention.

Rebase for harmony

git rebase <base-branch>

Purpose: Reapply commits, creating a streamlined history.

Abort with grace

git merge --abort
git rebase --abort

Purpose: Cancel a merge or rebase when conflicts arise, preserving simplicity.

7. Remote Repos 🌐

Connect with the world

git remote add <remote-name> <repository-url>

Purpose: Establish a meaningful connection to a remote repository.

List your connections

git remote -v

Purpose: Display your remote repositories, keeping your focus sharp.

Fetch mindfully

git fetch <remote-name>

Purpose: Retrieve changes without merging, ensuring control over your work.

Pull with purpose

git pull <remote-name> <branch-name>

Purpose: Merge remote changes, embracing collaboration.

Share your minimalism

git push <remote-name> <branch-name>

Purpose: Inspire others by pushing your local changes to a remote repository.

8. Deleting & Resetting ♻️

Caution: git reset --hard will remove your working directory changes. Be sure to stash any valuable local changes before running this command.

Shed the past

git reset --hard HEAD~1

Purpose: Free yourself from the last commit, returning to a simpler state.

Remove specific baggage

git reset --hard <commit-hash>

Purpose: Let go of a specific commit, decluttering your working directory.

Force push with caution

git push origin HEAD --force

Purpose: Share your minimalist approach after removing a commit, but tread lightly as it may disrupt others.

Reset to a clean slate

git reset --hard HEAD

Purpose: Embrace the present by discarding all changes and returning to the latest commit.

Rediscover the past

git reflog

Purpose: Uncover a log of all reference updates, including “deleted” commits, allowing you to reevaluate your minimalist journey.