Skip to main content

Git

A Tale of a New Developer and Git 💻🚀

Alex, a bright-eyed new developer, was eager to dive into his first open-source project 🚀. The project's code was hosted on a remote repository, and Alex's first task was to get a local copy. He opened his terminal and typed: git clone https://github.com/open-source-project/awesome-project.git This command, git clone, fetched the entire repository from GitHub and created a local copy on his machine. 🌎 Now, Alex was ready to start contributing. He began by creating a new branch for his feature: 🌳 git checkout -b new-feature

Git Add . (All)

git add . stages all changes in the current directory and everything below it — modified files, new files, and deleted files — in a single command. It's the fastest way to prepare everything for a commit when you want the full working-directory state captured. This is the fourth post in this site's Git command guide, following Git Add.

Git Push

git push uploads local commits to a remote repository. This guide covers upstream tracking with -u, --force vs --force-with-lease, and how to resolve a real rejected-push error.

Git Pull

git pull fetches and merges remote changes. This guide covers the divergent branches reconciliation warning, setting pull.rebase and pull.ff, and a merge-vs-rebase comparison table.

Git Checkout

git checkout switches branches and restores files. This guide covers detached HEAD state and the checkout vs switch vs restore split introduced in Git 2.23, with a side-by-side comparison table.

Git Branch

git branch lists, creates, renames, and deletes branches. This guide covers renaming master to main with -m, the difference between -d and -D, and a reference table of common flags.

Git Log

git log displays commit history. This guide covers --oneline --graph --all for compact history, git log -p for diffs, filtering by author and date, and a flag reference table.

Git Clone

git clone copies an entire remote repository locally. This guide covers shallow clones with --depth, cloning specific branches, submodules, SSH vs HTTPS, and fixing a Permission denied (publickey) error.

Git Add

git add is the command that stages changes from your working directory into Git's index, marking them to be included in the next commit. Staging is an intermediate step that gives you precise control — you can add one file at a time, leaving other modified files unstaged until a later commit. This is the third post in this site's Git command guide, following Git Clone.

Git Commit

git commit saves your staged changes to the local repository as a permanent snapshot. It creates a new commit object with a unique identifier based on the changes made, along with a message that describes them. This is the fifth post in this site's Git command guide, following Git Add . (All).