DEV Community

Cover image for 5 Git Commands I Use Every Day as a Developer
Sanjay Rajpurohit
Sanjay Rajpurohit

Posted on

5 Git Commands I Use Every Day as a Developer

If you're learning Git, you don't need to memorize 50 commands.

In my daily development workflow, I mostly use a small set of commands again and again.

Here are 5 Git commands that every beginner should understand.

1. git clone

When you want to download an existing project from GitHub:

git clone https://github.com/username/project.git

This creates a local copy of the repository on your computer.

After cloning:

cd project

Now you can start working on the project.

2 git status

This is probably the Git command I use the most.

git status

It tells you what's happening in your repository.

For example:

modified: app.js
modified: styles.css
untracked: config.js

Before committing anything, I usually run:

git status

It helps me see exactly what I've changed.

3.git add

After making changes, you need to tell Git which files you want to include in your next commit.

For one file:

git add app.js

For all changed files:

git add

Think of git add as:

"Git, I want to include these changes."

4. git commit

Now save those staged changes with a message:

git commit -m "Add login validation"

A good commit message should briefly explain what changed.

For example:

git commit -m "Fix navbar on mobile"

is much more useful than:

git commit -m "changes"

Small, meaningful commits make your project history much easier to understand.

5. git push

After committing your changes locally, you can send them to the remote repository:

git push

Now your changes are available on GitHub or another Git hosting service.

A simple workflow looks like this:

git status
git add .
git commit -m "Add new feature"
git push

## My simple Git workflow

Most of the time, my workflow looks something like this:

Start work
↓
git pull
↓
Write code
↓
git status
↓
git add .
↓
git commit -m "Describe the change"
↓
git push

You don't need to memorize every Git command to get started.

Start with these few commands and learn more as you actually need them.

Git becomes much easier once you stop trying to memorize it and start using it.

Top comments (0)