15 Git Commands That Cover 90% of a Developer's Daily Work

A practical guide to the 15 essential Git commands that handle the vast majority of everyday version control tasks, from cloning and committing to branching, merging, rebasing, and undoing changes.

To accomplish 90% of your daily tasks, it's enough to confidently master a small set of key commands. In this article, I'll walk through each of them with clear explanations and practical examples.

1. git clone

git clone downloads a remote repository to your local machine. It automatically sets up the connection to the remote server (called origin), so you can immediately start working.

git clone https://github.com/user/repo.git

After this command, you'll have a complete local copy of the project with all its history.

2. git status

git status shows the current state of your repository: which files have been modified, which are staged for commit, and which are untracked.

git status

This is the command you'll run most often. It tells you exactly where things stand before making any decisions.

3. git add

git add moves changes from your working directory to the staging area — a preparation zone before committing.

git add file.txt        # stage a specific file
git add .               # stage all changes in current directory

Think of the staging area as a box where you place items before shipping them (committing).

4. git commit

git commit records the staged changes in the project history with a descriptive message.

git commit -m "Add user authentication module"

A good commit message explains why the change was made, not just what was changed. Keep messages concise but meaningful.

5. git push

git push sends your local commits to the remote repository, making them available to your teammates.

git push origin main

If the branch already tracks a remote, a simple git push is sufficient.

6. git pull

git pull downloads changes from the remote repository and merges them with your local branch. It's essentially a combination of git fetch and git merge.

git pull origin main

Always pull before pushing to avoid unnecessary merge conflicts.

7. git branch

git branch manages branches — independent lines of development.

git branch                    # list all local branches
git branch feature-login      # create a new branch
git branch -d feature-login   # delete a branch

Branches let you work on features or fixes without affecting the main codebase.

8. git checkout

git checkout switches between branches or restores files to a previous state.

git checkout feature-login        # switch to branch
git checkout -b new-feature       # create and switch
git checkout -- file.txt          # discard changes in file

Note: for branch switching, the newer git switch command is preferred.

9. git switch

git switch is a modern, safer alternative to git checkout specifically designed for switching branches.

git switch main                   # switch to main
git switch -c new-feature         # create and switch

Unlike checkout, switch won't accidentally overwrite your files — it's designed to do one thing well.

10. git merge

git merge combines changes from one branch into another.

git checkout main
git merge feature-login

If there are no conflicts, Git creates a merge commit automatically. If conflicts exist, you'll need to resolve them manually before completing the merge.

11. git rebase

git rebase rewrites history by replaying your commits on top of another branch, creating a clean, linear history.

git checkout feature-login
git rebase main

Important: Never rebase commits that have already been pushed to a shared repository. Rebase rewrites commit hashes, which can cause serious problems for other team members.

12. git log

git log shows the commit history.

git log                           # full log
git log --oneline                 # compact one-line format
git log --oneline --graph --all   # visual branch graph

The --oneline --graph combination is especially useful for understanding the branching structure of a project.

13. git diff

git diff shows differences between various states.

git diff                  # unstaged changes vs last commit
git diff --staged         # staged changes vs last commit
git diff main..feature    # differences between branches

Always review your changes with git diff before committing to catch any mistakes.

14. git stash

git stash temporarily saves uncommitted changes so you can switch to another task.

git stash                 # save current changes
git stash pop             # restore saved changes
git stash list            # view all stashes

Stash is perfect for those "quick fix" moments when you need to switch branches but aren't ready to commit your current work.

15. git reset

git reset undoes changes with three different modes:

git reset --soft HEAD~1   # undo commit, keep changes staged
git reset --mixed HEAD~1  # undo commit, unstage changes (default)
git reset --hard HEAD~1   # undo commit, discard all changes

Warning: --hard permanently deletes changes. Use it with extreme caution.

Conclusion

These 15 commands cover the vast majority of what you'll encounter in daily Git usage. Master them, and you'll handle most version control scenarios confidently. I recommend practicing on a test repository to build muscle memory before working on production code.

FAQ

What is this article about in one sentence?

This article explains the core idea in practical terms and focuses on what you can apply in real work.

Who is this article for?

It is written for engineers, technical leaders, and curious readers who want a clear, implementation-focused explanation.

What should I read next?

Use the related articles below to continue with closely connected topics and concrete examples.