DEV Community

Meena Dhakad
Meena Dhakad

Posted on

🧰 Common Git Commands for Beginners – A Quick Guide

**πŸ” 1. git init
**Initializes a new Git repository in your project folder.

bash
Copy
Edit
git init
βœ… Use when starting a new project that you want to track with Git.

**πŸ“₯ 2. git clone
**Clones an existing repository from GitHub or any remote source.

bash
Copy
Edit
git clone
βœ… Use to copy code from a remote repo to your local machine.

**πŸ“„ 3. git status
**Shows the current status of your working directory.

bash
Copy
Edit
git status
βœ… See which files have been modified, added, or deleted before committing.

**βž• 4. git add
**Adds files to the staging area (preparing them to be committed).

bash
Copy
Edit
git add filename

or add everything

git add .
βœ… Use after editing/creating files to stage them.

**πŸ’Ύ 5. git commit
**Commits your changes with a message.

bash
Copy
Edit
git commit -m "your message here"
βœ… Records the snapshot of your changes.

**πŸ”„ 6. git pull
**Fetches and merges changes from a remote repository.

bash
Copy
Edit
git pull origin main
βœ… Use before you start working to make sure you're updated.

**πŸ“€ 7. git push
**Pushes your local commits to the remote repository.

bash
Copy
Edit
git push origin main
βœ… Uploads your code to GitHub or other remote.

**πŸ”™ 8. git log
**Shows a history of commits.

bash
Copy
Edit
git log
βœ… Useful to review what changes have been made and by whom.

πŸ—‘οΈ 9. git rm
Removes a file from your repo and stage the deletion.

bash
Copy
Edit
git rm filename
πŸ€” Final Thoughts
Learning Git is a journeyβ€”but it starts with just a few commands. Once you're comfortable with these basics, you'll be able to collaborate, track changes, and contribute to projects with ease.

πŸ”— Was this helpful? Follow me for more beginner-friendly technical guides!

Top comments (0)