Tuesday, December 23, 2025

thumbnail

Git Commands Every Developer Should Know

 Git Commands Every Developer Should Know


Git is a distributed version control system that helps developers track changes, collaborate efficiently, and manage code history. Knowing the essential Git commands is crucial for every developer, whether beginner or experienced.


1. Basic Git Setup

git config


Used to configure Git settings.


git config --global user.name "Your Name"

git config --global user.email "you@example.com"


2. Creating and Cloning Repositories

git init


Initializes a new Git repository.


git init


git clone


Creates a copy of an existing repository.


git clone <repository-url>


3. Checking Repository Status

git status


Shows the current state of the working directory.


git status


git log


Displays commit history.


git log


4. Tracking and Saving Changes

git add


Stages changes for commit.


git add .


git commit


Saves staged changes to the repository.


git commit -m "Commit message"


5. Branching and Merging

git branch


Lists or creates branches.


git branch

git branch new-feature


git checkout / git switch


Switches branches.


git checkout new-feature

git switch main


git merge


Merges branches.


git merge new-feature


6. Synchronizing with Remote Repositories

git remote


Manages remote connections.


git remote -v


git pull


Fetches and merges changes from remote.


git pull origin main


git push


Uploads local changes to remote.


git push origin main


7. Undoing Changes

git reset


Unstages or resets commits.


git reset file.txt


git checkout --


Discards local changes.


git checkout -- file.txt


git revert


Creates a new commit that undoes a previous commit.


git revert <commit-hash>


8. Viewing Differences

git diff


Shows changes between commits or working directory.


git diff


9. Stashing Changes

git stash


Temporarily saves changes.


git stash

git stash pop


10. Tagging Releases

git tag


Marks specific commits (often for releases).


git tag v1.0

git push origin v1.0


11. Cleaning and Maintenance

git clean


Removes untracked files.


git clean -f


12. Useful Git Shortcuts


git log --oneline – Compact commit history


git branch -d branch-name – Delete branch


git fetch – Download changes without merging


Conclusion


Mastering these Git commands helps developers work more efficiently, collaborate better, and manage code confidently. While Git has many advanced features, these core commands cover most daily development tasks.

Learn Full Stack JAVA Course in Hyderabad

Read More

Getting Started with Git and GitHub

๐Ÿ› ️ Tools & Version Control

NoSQL vs SQL – What’s the Difference?

Spring Data JPA for Database Access

Visit Our Quality Thought Institute in Hyderabad

Get Directions 

Subscribe by Email

Follow Updates Articles from This Blog via Email

No Comments

About

Search This Blog

Powered by Blogger.

Blog Archive