Git Articles

All articles

SSH vs HTTPS for Git Remotes — Which Should You Use?

Git repositories can be accessed over SSH (using key-based authentication) or HTTPS (using a username/password or personal access token).

How to Squash Multiple Commits Into One in Git

Squashing combines several commits into a single one, useful for cleaning up a feature branch's history before merging.

How to Resolve a Merge Conflict in Git

A merge conflict happens when Git can't automatically combine changes because the same lines were edited differently on both sides being merged.

What Is .gitattributes and What Is It For?

A .gitattributes file lets you define path-specific attributes that control how Git handles certain files, most commonly line-ending normalization.

git reset --soft vs --mixed vs --hard Explained

git reset moves the current branch pointer to a different commit, and its mode controls what happens to the changes in between.

How to View a Specific Commit in Git (git show)

git show displays detailed information about a single commit, including its metadata and the full diff it introduced.

How to Configure Git Settings (git config)

git config reads and writes configuration values that control how Git behaves, such as your identity and command aliases.

What Is git worktree and When Should You Use It?

git worktree lets you check out multiple branches of the same repository into separate directories at the same time, without cloning it again.

What Are Git Submodules and How Do They Work?

A Git submodule embeds one Git repository inside another as a subdirectory, pinned to a specific commit.

How to Remove Untracked Files in Git (git clean)

git clean deletes files that are untracked by Git — files never added or committed — from your working directory.

How to Recover Lost Commits With git reflog

git reflog records every position HEAD has pointed to, letting you recover commits that seem lost after a reset, rebase, or branch deletion.

How to Use Interactive Rebase in Git (git rebase -i)

Interactive rebase lets you rewrite a range of commits — reordering, combining (squashing), editing, or dropping them — before they're shared.

How to Find a Bad Commit With git bisect

git bisect performs a binary search through your commit history to find exactly which commit introduced a bug.

How to Find Who Changed a Line With git blame

git blame annotates every line of a file with the commit and author that last modified it.

How to Create and Use Tags in Git (git tag)

git tag marks a specific commit with a fixed, memorable name, most commonly used to mark release versions.

How to Manage Remote Repositories in Git (git remote)

git remote manages the set of remote repository URLs your local repository knows about, most commonly a single "origin".

How to Check Repository State in Git (git status)

git status summarizes the current state of your working directory and staging area — which files are modified, staged, or untracked.

How to View Changes in Git (git diff)

git diff shows the exact line-by-line differences between your working directory, the staging area, and the last commit.

How to View a Condensed Git History (git log --oneline)

git log --oneline shows each commit as a single line with its short hash and message, making long histories much easier to scan.

How to View Commit History in Git (git log)

git log displays the commit history of the current branch, most recent commit first.

git checkout vs git switch — Which Should You Use?

git switch was introduced to split git checkout's overloaded behavior — switching branches — into its own, less error-prone command.

How to List, Create, and Delete Branches in Git (git branch)

git branch manages branches — separate, independent lines of development within the same repository.

git fetch vs git pull — What's the Difference?

git fetch downloads new commits and branches from a remote without changing any of your local branches, letting you review changes before merging.

How git pull Works (Fetch + Merge)

git pull downloads new commits from a remote branch and immediately merges them into your current local branch.

How to Push Commits to a Remote in Git (git push)

git push uploads your local commits to a remote repository, updating the branch there to match your local branch.

How to Edit the Last Commit in Git (git commit --amend)

git commit --amend replaces the most recent commit with a new one, letting you fix its message or add forgotten changes.

How to Commit Changes in Git (git commit)

git commit records the currently staged changes as a new snapshot in the repository's history, along with a message describing them.

How to Stage Changes in Git (git add)

git add moves changes from your working directory into the staging area, marking them to be included in the next commit.

How to Clone a Git Repository (git clone)

git clone downloads a complete copy of a remote repository, including its full history, into a new local directory.

How to Initialize a New Git Repository (git init)

git init creates a new, empty Git repository in the current directory by adding a hidden .git folder that stores all version history.

How to Use git cherry-pick to Apply a Specific Commit

git cherry-pick applies the changes from one specific commit onto your current branch, without merging the entire branch it came from.

How to Use git stash to Save Uncommitted Changes

git stash temporarily shelves uncommitted changes so you can switch branches cleanly, then restore them later with git stash pop.

Why Is .gitignore Not Working? How to Fix It

gitignore only affects untracked files — if a file is already committed, adding it to .gitignore won't stop Git from tracking it. Learn how to fix it.

What Does "Detached HEAD" Mean in Git?

A detached HEAD means you've checked out a specific commit instead of a branch. Learn what it means, why it happens, and how to save work made in this state.

Git Merge vs Rebase — What's the Difference?

git merge preserves history with a merge commit; git rebase rewrites your branch's commits onto a new base for a linear history. Learn when to use each.

How to Undo or Revert the Last Git Commit

Undo the last git commit with git reset (keeping or discarding changes) or git revert (creating a new commit that undoes it) — learn when to use each.