DEV Community

Cover image for Must-Know Git Commands for Everyday Developers
A. Moreno
A. Moreno

Posted on

Must-Know Git Commands for Everyday Developers

Let’s be honest — Git can be overwhelming at first. But after working on multiple front-end projects with teams, I’ve realized that you really only need a handful of Git commands to get through most day-to-day development tasks.

Here are the essentials that I keep coming back to — whether I’m working solo or collaborating on a team.


1. git clone

Copy a remote repository to your local machine.

git clone https://github.com/username/repo.git
Enter fullscreen mode Exit fullscreen mode

When to use: When you want to start working on a project from GitHub or any remote repo.


2. git status

Check which files have been changed, staged, or committed.

git status
Enter fullscreen mode Exit fullscreen mode

When to use: All the time! It helps you see what’s going on before you commit or push.


3. git add

Stage changes so Git knows what to include in the next commit.

git add filename.js      # stage a specific file
git add .                # stage everything
Enter fullscreen mode Exit fullscreen mode

When to use: Right before you commit. Think of it like selecting files to include in your snapshot.


4. git commit

Create a snapshot of your staged changes.

git commit -m "Describe what you changed"
Enter fullscreen mode Exit fullscreen mode

When to use: After staging your changes, when you’re happy with what you’re about to save.


5. git push

Send your local commits to the remote repo.

git push origin main
Enter fullscreen mode Exit fullscreen mode

When to use: When you want to upload your latest commits to GitHub (or wherever your remote is hosted).


6. git pull

Bring down the latest changes from the remote to your local branch.

git pull origin main
Enter fullscreen mode Exit fullscreen mode

When to use: Before you start working, or when your teammate just pushed something and you want to stay up to date.


7. git checkout

Switch branches or restore files.

git checkout -b new-feature    # create + switch to a new branch
git checkout main              # switch back to main
Enter fullscreen mode Exit fullscreen mode

When to use: When creating new features or reviewing code on a different branch.


8. git branch

List, create, or delete branches.

git branch             # list all branches
git branch new-branch  # create a new branch
git branch -d old-one  # delete a branch
Enter fullscreen mode Exit fullscreen mode

When to use: For keeping your work organized and separate from others.


9. git log

See your commit history.

git log
Enter fullscreen mode Exit fullscreen mode

When to use: When you want to check what’s been committed or who made changes.


10. git stash

Temporarily save your changes without committing.

git stash
git stash pop
Enter fullscreen mode Exit fullscreen mode

When to use: If you’re in the middle of something but need to switch branches — and don’t want to commit yet.


Bonus: .gitignore

Tell Git to ignore specific files or folders (e.g., node_modules/, env.local).

node_modules/
.env
dist/
Enter fullscreen mode Exit fullscreen mode

When to use: Always include a .gitignore file to keep your repo clean and avoid committing unnecessary stuff.


Wrap-Up

You don’t need to master every Git command to be productive. Get familiar with these, and you’ll be just fine in most development scenarios — whether solo or with a team.

Top comments (0)