ReadmeBuddy LogoReadmeBuddy
Back to BlogLearn Git

10 Essential Git Commands Every Developer Should Know

coder-shubh
10 Essential Git Commands Every Developer Should Know

๐—œ๐—ป๐˜๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜๐—ถ๐—ผ๐—ป

Git is the backbone of modern development workflows. Whether you're working on a solo side project or collaborating with a large team, mastering Git commands is essential. In this post, weโ€™ll go over 10 fundamental Git commands that every developer should know to manage code efficiently and confidently.

๐Ÿ”ง ๐Ÿญ. ๐—ด๐—ถ๐˜ ๐—ถ๐—ป๐—ถ๐˜

Initializes a new Git repository in your project folder.

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐š’ฬฒ๐š—ฬฒ๐š’ฬฒ๐šฬฒ

This creates a .git directory and enables version tracking for your files.

๐Ÿ”„ ๐Ÿฎ. ๐—ด๐—ถ๐˜ ๐—ฐ๐—น๐—ผ๐—ป๐—ฒ

Clones an existing Git repository (usually from GitHub) to your local machine.

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐šŒฬฒ๐š•ฬฒ๐š˜ฬฒ๐š—ฬฒ๐šŽฬฒโ€‚ฬฒ๐š‘ฬฒ๐šฬฒ๐šฬฒ๐š™ฬฒ๐šœฬฒ:ฬฒ/ฬฒ/ฬฒ๐šฬฒ๐š’ฬฒ๐šฬฒ๐š‘ฬฒ๐šžฬฒ๐š‹ฬฒ.ฬฒ๐šŒฬฒ๐š˜ฬฒ๐š–ฬฒ/ฬฒ๐šžฬฒ๐šœฬฒ๐šŽฬฒ๐š›ฬฒ๐š—ฬฒ๐šŠฬฒ๐š–ฬฒ๐šŽฬฒ/ฬฒ๐š›ฬฒ๐šŽฬฒ๐š™ฬฒ๐š˜ฬฒโ€“ฬฒ๐š—ฬฒ๐šŠฬฒ๐š–ฬฒ๐šŽฬฒ.ฬฒ๐šฬฒ๐š’ฬฒ๐šฬฒ

You get a full copy of the repo including history and branches.

๐Ÿ’พ ๐Ÿฏ. ๐—ด๐—ถ๐˜ ๐—ฎ๐—ฑ๐—ฑ

Stages changes in your working directory for the next commit.

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐šŠฬฒ๐šฬฒ๐šฬฒโ€‚ฬฒ.ฬฒ

or

git add filename.js

Use . to add all changes, or specify individual files.

โœ… ๐Ÿฐ. ๐—ด๐—ถ๐˜ ๐—ฐ๐—ผ๐—บ๐—บ๐—ถ๐˜

Saves your staged changes to the local repository with a message.

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐šŒฬฒ๐š˜ฬฒ๐š–ฬฒ๐š–ฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒโ€“ฬฒ๐š–ฬฒโ€‚ฬฒ"ฬฒ๐™ฐฬฒ๐šฬฒ๐šฬฒโ€‚ฬฒ๐š•ฬฒ๐š˜ฬฒ๐šฬฒ๐š’ฬฒ๐š—ฬฒโ€‚ฬฒ๐šŒฬฒ๐š˜ฬฒ๐š–ฬฒ๐š™ฬฒ๐š˜ฬฒ๐š—ฬฒ๐šŽฬฒ๐š—ฬฒ๐šฬฒ"ฬฒ

Each commit is like a snapshot of your project at a moment in time.

๐Ÿš€ ๐Ÿฑ. ๐—ด๐—ถ๐˜ ๐—ฝ๐˜‚๐˜€๐—ต

Uploads your local commits to a remote repository like GitHub.

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐š™ฬฒ๐šžฬฒ๐šœฬฒ๐š‘ฬฒโ€‚ฬฒ๐š˜ฬฒ๐š›ฬฒ๐š’ฬฒ๐šฬฒ๐š’ฬฒ๐š—ฬฒโ€‚ฬฒ๐š–ฬฒ๐šŠฬฒ๐š’ฬฒ๐š—ฬฒ

Make sure you're pushing to the correct branch (main, master, or others).

โฌ‡๏ธ ๐Ÿฒ. ๐—ด๐—ถ๐˜ ๐—ฝ๐˜‚๐—น๐—น

Fetches changes from the remote repo and merges them into your local branch.

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐š™ฬฒ๐šžฬฒ๐š•ฬฒ๐š•ฬฒโ€‚ฬฒ๐š˜ฬฒ๐š›ฬฒ๐š’ฬฒ๐šฬฒ๐š’ฬฒ๐š—ฬฒโ€‚ฬฒ๐š–ฬฒ๐šŠฬฒ๐š’ฬฒ๐š—ฬฒ

Useful for syncing changes made by others before you start new work.

๐Ÿ” ๐Ÿณ. ๐—ด๐—ถ๐˜ ๐˜€๐˜๐—ฎ๐˜๐˜‚๐˜€

Shows the current state of your working directory and staging area.

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐šœฬฒ๐šฬฒ๐šŠฬฒ๐šฬฒ๐šžฬฒ๐šœฬฒ

Tells you which files are modified, staged, or untracked.

๐Ÿ”„ ๐Ÿด. ๐—ด๐—ถ๐˜ ๐—ฐ๐—ต๐—ฒ๐—ฐ๐—ธ๐—ผ๐˜‚๐˜

Switches to a different branch or restores files.

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐šŒฬฒ๐š‘ฬฒ๐šŽฬฒ๐šŒฬฒ๐š”ฬฒ๐š˜ฬฒ๐šžฬฒ๐šฬฒโ€‚ฬฒโ€“ฬฒ๐š‹ฬฒโ€‚ฬฒ๐š—ฬฒ๐šŽฬฒ๐š ฬฒโ€“ฬฒ๐šฬฒ๐šŽฬฒ๐šŠฬฒ๐šฬฒ๐šžฬฒ๐š›ฬฒ๐šŽฬฒ

Use -b to create a new branch and switch to it at once.

๐Ÿงน ๐Ÿต. ๐—ด๐—ถ๐˜ ๐—ฏ๐—ฟ๐—ฎ๐—ป๐—ฐ๐—ต

Lists branches or creates new ones.

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐š‹ฬฒ๐š›ฬฒ๐šŠฬฒ๐š—ฬฒ๐šŒฬฒ๐š‘ฬฒ

or

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐š‹ฬฒ๐š›ฬฒ๐šŠฬฒ๐š—ฬฒ๐šŒฬฒ๐š‘ฬฒโ€‚ฬฒ๐š—ฬฒ๐šŽฬฒ๐š ฬฒโ€“ฬฒ๐šฬฒ๐šŽฬฒ๐šŠฬฒ๐šฬฒ๐šžฬฒ๐š›ฬฒ๐šŽฬฒ

Keep your main branch clean by developing in separate branches.

โช ๐Ÿญ๐Ÿฌ. ๐—ด๐—ถ๐˜ ๐—น๐—ผ๐—ด

Displays commit history.

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐š•ฬฒ๐š˜ฬฒ๐šฬฒโ€‚ฬฒโ€“ฬฒโ€“ฬฒ๐š˜ฬฒ๐š—ฬฒ๐šŽฬฒ๐š•ฬฒ๐š’ฬฒ๐š—ฬฒ๐šŽฬฒ

See who made which changes and when โ€” great for debugging and collaboration.

๐Ÿšง ๐—•๐—ผ๐—ป๐˜‚๐˜€: ๐—–๐—ผ๐—บ๐—บ๐—ผ๐—ป ๐—ง๐—ฟ๐—ผ๐˜‚๐—ฏ๐—น๐—ฒ๐˜€๐—ต๐—ผ๐—ผ๐˜๐—ถ๐—ป๐—ด ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ๐˜€ ๐—จ๐—ป๐—ฑ๐—ผ ๐—น๐—ฎ๐˜€๐˜ ๐—ฐ๐—ผ๐—บ๐—บ๐—ถ๐˜:

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐š›ฬฒ๐šŽฬฒ๐šœฬฒ๐šŽฬฒ๐šฬฒโ€‚ฬฒโ€“ฬฒโ€“ฬฒ๐šœฬฒ๐š˜ฬฒ๐šฬฒ๐šฬฒโ€‚ฬฒ๐™ทฬฒ๐™ดฬฒ๐™ฐฬฒ๐™ณฬฒ~ฬฒ๐Ÿทฬฒ

Discard all local changes:

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐š›ฬฒ๐šŽฬฒ๐šœฬฒ๐šŽฬฒ๐šฬฒโ€‚ฬฒโ€“ฬฒโ€“ฬฒ๐š‘ฬฒ๐šŠฬฒ๐š›ฬฒ๐šฬฒ

๐—ฅ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ ๐˜€๐˜๐—ฎ๐—ด๐—ฒ๐—ฑ ๐—ณ๐—ถ๐—น๐—ฒ:

๐šฬฒ๐š’ฬฒ๐šฬฒโ€‚ฬฒ๐š›ฬฒ๐šŽฬฒ๐šœฬฒ๐šŽฬฒ๐šฬฒโ€‚ฬฒ๐™ทฬฒ๐™ดฬฒ๐™ฐฬฒ๐™ณฬฒโ€‚ฬฒ๐šฬฒ๐š’ฬฒ๐š•ฬฒ๐šŽฬฒ๐š—ฬฒ๐šŠฬฒ๐š–ฬฒ๐šŽฬฒ

๐Ÿ ๐—–๐—ผ๐—ป๐—ฐ๐—น๐˜‚๐˜€๐—ถ๐—ผ๐—ป These Git commands form the foundation of version control. Whether you're a junior developer or working in DevOps, mastering these will improve your confidence and collaboration in any codebase. Bookmark this post or share it with a teammate whoโ€™s just getting started!