Git basics

Published: December 23, 2025

Rolling Post
Last updated: December 23, 2025

Git - Version control system

Uses

  • Tracking code changes
  • Collaborating

Key Git Concepts

  1. Repository - A folder where git tracks project and history

  2. Clone(Verb!) - Make a copy of a remote repo

  3. Stage (Verb!)- Tell git of changes to be saved next

  4. Commit(Verb!)- Save a snapshot of staged changes

  5. Tracked file - A file that git is watching for changes

Git Install

sudo pacman -Syu git

Git configuration

  • Set username git config --global user.name "name"

  • Set email git config --global user.email "email"

  • Set default branch git config --global init.defaultBranch main (Set to main)

The configurations can also be local or system - git config --local - Applies to the local repo

  • git config --system - Applies to all users and in all repos

Initialize git repo

git init

Common commands

  • git status - Check which files are tracked( or not tracked?)
  • git add <file> - Stage a file
  • git add -A / git add --all - Stage all changes
  • git restore --staged <file> - Unstage a file
  • git commit -m "Message" - Commit staged changes with a message
  • git commit -a -m "Message" - Commit all tracked changes skipping staging. (Does not work for new/untracked files)
  • git log - See commit history
  • git commit - Opens the configured editor for the comment.
  • git commit --amend -m "Corrected message" - Correct a git commit message.
  • git commit --amend - (After git add) - If forgotten to add a file before commit.
  • git reset --soft HEAD~1 - Undo last commit and keep changes staged.

Best practices ( I intent to start following these)

  • Keep the first line short( Mine are always short)
  • Use the imperative mood ( "Add" instead of "Added") - I have been mixing these.
  • Leave a blank line after the summary then add more details if needed. ( All my commit messages have been summaries thus far)
  • Describe why the changes were made not just what changed.

Git Tagging ( First time I am using this git feature)

Git tag - A label or bookmark for a specific commit.

Commands

  • git tag <tagname> - Create a lightweight tag.
  • git tag -a <tagname> - Create annotated tag.
  • git tag - List tags
  • git show <tagname> - Show tag details
  • git tag <tagname> <commit-hash> - Tag a specific commit

Annotated tag - Stores author, date and message
Lightweight tag - A simple name for a commit

Common tag types

  • Releases - Mark when a project is ready for release
  • Milestones - Highlight major milestones e.g. Big feature finished or a bug is fixed.
  • Deployment - Used by some deployment tools ( I guess I'll find out this one "one day")

git push --tags - Push all tags
git tag -d <tagname> - Delete a tag locally
git push origin --delete tag <tagname> - Delete remote tag

Git Stash

Save uncommitted changes and return to a clean working directory. Changes can be restored later.

Related Posts

Vim basics

Programming

Modes

Normal Mode

Used for :
1. Moving the cursor
2. Deleting characters, words, lines etc
3. Performing …

Dec 23, 2025

Bash scripting

Programming

Bash (Bourne-Again SHell) - Used to write scripts and run commands in unix based systems.

Shell - Text based …

Dec 23, 2025