Skip to main content

Version Control

Browse all articles, tutorials, and guides about Version Control

21posts

Guides

Posts

Git
|10 min read

How Can I Delete a Remote Tag?

Learn how to delete Git tags from remote repositories safely. Understand the difference between local and remote tag deletion, and discover best practices for managing release tags in team environments.

Git
|6 min read

Make an Existing Git Branch Track a Remote Branch

Run git branch --set-upstream-to=origin/branch-name (short: git branch -u origin/branch-name). Not on the remote yet? Run git push -u origin branch-name.

Git
|5 min read

Git Clone a Specific Branch with --single-branch

Clone only one branch with git clone -b branch-name --single-branch <repo-url>. Add --depth 1 to download just the latest commit and save more space.

Git
|5 min read

How to Get the Current Branch Name in Git

Need to programmatically get the current Git branch name? Learn multiple methods to retrieve the branch name for scripts, CI/CD pipelines, and shell prompts.

Git
|13 min read

Delete a Commit from a Git Branch: Reset, Rebase or Revert

Remove the last commit with git reset --hard HEAD~1, drop an older one with git rebase -i, or undo a pushed commit safely with git revert <commit-hash>.

Git
|5 min read

How do I Add an Empty Directory to a Git Repository?

Git does not track empty directories by design. Learn practical workarounds to include empty folders in your repository using .gitkeep files and understand why this limitation exists.

Git
|6 min read

How to Update or Sync a Forked Repository on GitHub

Your fork is behind the original repository? Learn how to sync your GitHub fork with the upstream repository and keep it up to date with the latest changes.

Git
|5 min read

How to List All Files in a Git Commit

Need to see which files were changed in a commit? Learn how to list all files modified, added, or deleted in any Git commit using log and show commands.

Git
|9 min read

Git File History: View the Changes Made to a File

Run git log --follow -p -- path/to/file to list the commits that changed a file, with patches, across renames. git blame shows who last changed each line.

Terraform
|14 min read

Should .terraform.lock.hcl Be in .gitignore? Checksums and Versions

No: commit .terraform.lock.hcl. Learn what the lock file records, how version constraints work, how to fix checksum mismatch and "Invalid legacy provider address" errors, how to install a specific Terraform version, and which providers manage on-premises servers.

Git
|14 min read

Undo or Abort a Git Merge, and Resolve Merge Conflicts

Undo a merge with git reset --merge ORIG_HEAD, stop one with git merge --abort, resolve conflicts, and fix "refusing to merge unrelated histories".

Git
|6 min read

Git Diff Between Two Branches: Files, Commits and Stats

git diff main..feature shows changed lines, git log main..feature lists commits main does not have, and git diff --stat main feature sums it up per file.

Git
|12 min read

How to Squash the Last N Commits and Change Commit Authors in Git

Squash the last N commits with git reset --soft or git rebase -i, use fixup commits, and fix commit authors with --amend, rebase --exec or a mailmap.

Git
|13 min read

How to Push a New Local Branch to Remote Git Repository and Track It

Push a new branch with git push -u origin <branch>, fix "src refspec does not match any", and rename or delete a branch locally and on the remote.

Git
|11 min read

Move the Most Recent Commit(s) to a New Branch with Git

Learn how to move recent commits from your current branch to a new branch using git checkout, reset, and cherry-pick. Fix branch organization mistakes effectively.

Git
|5 min read

Remove a Git Submodule: deinit, git rm and Cleanup

Run git submodule deinit -f path, then git rm -f path, and commit. To delete the leftover Git data too, remove .git/modules/<name>, usually the same path.

Git
|6 min read

How to Undo a Git Rebase with ORIG_HEAD or reflog

Just rebased? Check git log -1 ORIG_HEAD, then run git reset --hard ORIG_HEAD. Otherwise find the old commit in git reflog. Mid-rebase: git rebase --abort.

Git
|10 min read

Git Fetch a Remote Branch and Check It Out Locally

Run git fetch origin branch-name, then git switch branch-name for a local branch that tracks origin/branch-name, or git switch --track origin/branch-name.

Git
|7 min read

How to Stash Only One File in Git

Need to temporarily save changes to just one file? Learn how to stash a single file in Git while leaving other changes in your working directory.

Git
|12 min read

Remove a File from Git Without Deleting It, or Undo git add

Stop tracking a file with git rm --cached and keep it on disk, unstage a file with git restore --staged, and commit only part of a file with git add -p.