I'm always excited to take on new projects and collaborate with innovative minds.

Address

98/4 Pravesh Vihar Shastri Nagar, Meerut

Social Links

Tutorials

Basic Git Commands Every Developer Should Know

Git is a powerful version control system that helps developers track changes in their code, collaborate with others, and maintain a clean history of their projects.

Basic Git Commands Every Developer Should Know

Git is a powerful version control system that helps developers track changes in their code, collaborate with others, and maintain a clean history of their projects. Below is a list of essential Git commands you should know when starting out.

1. Initialize a Git Repository

git init

Creates a new Git repository in your current directory.

2. Clone a Repository

git clone <repository_url>

Downloads a project and its entire version history from a remote repository.

3. Check Status

git status

Displays the state of your working directory and staging area.

4. Add Changes

git add <filename>
# OR to add all files:
git add .

Stages changes for the next commit.

5. Commit Changes

git commit -m "Your commit message"

Saves your staged changes with a descriptive message.

6. View Commit History

git log

Shows the history of commits made to the repository.

7. Push Changes to Remote

git push origin <branch_name>

Uploads your commits to a remote repository like GitHub or GitLab.

8. Pull Changes from Remote

git pull

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

9. Create a New Branch

git branch <branch_name>

Creates a new branch.

10. Switch to a Branch

git checkout <branch_name>
# OR in newer versions:
git switch <branch_name>

11. Create and Switch to a Branch

git checkout -b <branch_name>
# OR in newer versions:
git switch -c <branch_name>

12. Merge a Branch

git merge <branch_name>

Merges another branch into your current branch.

13. Delete a Branch

git branch -d <branch_name>

Deletes a branch locally.

14. Discard Changes

git checkout -- <file_name>

Reverts a file to the last committed version.

15. Check Remote URL

git remote -v

Displays the URLs of remote repositories connected to your local repo.

Git
2 min read
May 18, 2025
By Avnish Tomar
Share

Leave a comment

Your email address will not be published. Required fields are marked *

Related posts

Jun 20, 2025 • 3 min read
Design Patterns in Software Development

Software development is as much about writing functional code as it is...