Git Basics: The 8 Commands You Will Use Every Day
Git can look intimidating, with hundreds of commands and options. The good news is that day-to-day work only needs a small handful. Learn these eight and you can handle most projects with confidence.
1. git clone
git clone <url> downloads a full copy of a repository, including its whole history, to your computer. This is usually the first thing you do when joining a project.
2. git status
git status shows which files have changed, which are staged for the next commit, and which branch you are on. Run it often. It is the best way to know what is going on.
3. git add
git add <file> stages a change, meaning it will be included in your next commit. Use git add . to stage everything in the current folder, but check git status first so you do not commit something by accident.
4. git commit
git commit -m "message" saves a snapshot of your staged changes. Write messages that explain why you made the change, like "Fix login error when password is empty". Future you will be grateful.
5. git pull
git pull fetches changes other people have pushed and merges them into your branch. Pull before you start working to avoid conflicts later.
6. git push
git push uploads your commits to the shared repository so others can see them.
7. git branch and git switch
Branches let you work on a feature without touching the main code. git switch -c new-feature creates a branch and moves you to it. git switch main takes you back.
8. git log
git log --oneline shows a compact history of commits. It is useful for finding when something changed and who changed it.
A simple daily workflow
git pullto get the latest codegit switch -c my-changeto start a branch- Edit files, then
git addandgit commit git pushand open a pull request for review
Once these feel natural, you can explore more advanced tools like rebase and stash. But these eight will carry you a long way.