Highly recommended Git Commands for Beginners and Developers 2026

ABHILASH CA

Junior Devops Engineer

Last Updated: 22 August 2026
Highly recommended Git Commands for Beginners and Developers 2026
🖥️12,400+PCs Fixed
⭐4.9★Google Rating
⚡<15 minAvg. Response
🛡️ISO 27001Certified

Essential Git Commands and Its Examples

1. Git init

Initialize a new Git repository in the current directory

The first command you'll use when starting a new Git repository is git init. This command initializes an empty Git repository in the current directory.

Before you can start tracking changes in your project, you need to initiate a Git repository. The git init command creates a hidden .git directory in your project's root folder, setting up the repository's structure.

2. Git commit

Record staged changes in the repository's history

The git commit command records the changes made to the repository. You can add a message to describe the changes you've made.

Commits are at the heart of version control. They represent a snapshot of your project at a specific point in time. The git commit command allows you to save your changes with a descriptive message, making it easy to track progress.

git commit -m "Added login functionality"

3. Git branch

List, create, or delete branches

The git branch command lists all the branches in your repository. You can create new branches, delete branches, and switch between branches.

Branches in Git enable parallel development, allowing multiple features or bug fixes to be worked on simultaneously. You can create, list, or delete branches using the git branch command.

git branch

git branch new-feature

git branch -d obsolete-branch

4. Git checkout

Switch between branches or commits

The git checkout command allows you to switch between branches or to a specific commit. You can also use it to create a new branch from an existing one.

git checkout branch-name
git checkout commit-hash

5. Git merge

Merge changes from one branch into another

The git merge command allows you to merge changes from one branch into another. It's useful when working on a team, as it allows you to combine your changes with those of your colleagues.

When a feature or bug fix is complete in a branch, you can integrate those changes into another branch, typically the main branch, using the git merge command.

6. Git pull

Fetch changes from a remote repository and merges them into the current branch

The git pull command fetches changes from a remote repository and merges them with your local repository.

Collaborating with others often involves fetching their changes from a remote repository and incorporating them into your local branch. The git pull command simplifies this process.

git pull origin main

7. Git remote

Manage remote repositories

The git remote command allows you to manage the remote repositories associated with your local repository. You can add new remote repositories, remove them, or rename them.

With Git, you can collaborate with developers worldwide by connecting your local repository to remote repositories. The git remote command helps you manage these remote connections.

git remote add origin https://github.com/user/repo.git

8. Git clone

Create a local copy of a remote repository

The git clone command creates a copy of a remote repository on your local machine. You can use it to start working on a project that has already been created.

git clone https://github.com/user/repo.git

9. git status

To see what's changed since the last commit. It shows all the files that have been added and modified and are ready to be committed and files that are untracked. //Check repo status

git status

10. git add Readme.txt

To add a file Readme.txt to the staging area to track its changes.

// Add Readme.txt file to the staging area

git add Readme.txt

11. git commit -m “ ”

To commit our changes(taking a snapshot) and provide a message to remember for future reference.

// Commit staged changes with a descriptive

git commit -m “Created a Readme.txt”

12. git log

To check the history of commits for our reference.

// View commit history with details like author, date, and message

git log

13. git add --all

To add all files of the current directory to the staging area.

// Stage all files (tracked and untracked) in the current directory

git add --all

14. git add *.txt

To add all text files of the current directory to the staging area.

// Stage all .txt files in the current directory

git add *.txt

15. git add docs/*.txt

To add all text files of a particular directory(docs) to the staging area.

// Stage all .txt files inside the 'docs' folder

git add docs/*.txt

16. git add docs/

To add all files in a particular directory(docs) to the staging area. // Stage all files inside the 'docs' directory

git add docs/

17. git add “*.txt”

To add text files of the entire project to the staging area. // Stage all .txt files across the entire project (quotes handle globbing)

git add “*.txt”

18. git diff

To figure out what changes you made since the last commit.

// Show file changes not yet staged for commit

git diff

19. git reset head license

To undo the staging of the file that was added in the staging area.

// Unstage the 'license' file that was previously added

git reset head license

20. git checkout –license

To Blow away all changes since the last commit of the file.

// Discard local changes to 'license' file (revert to last commit)

git checkout –license

21. git commit -a -m “ ”

To add any of our tracked files to the staging area and commit them by providing a message to remember. //Automatically stage tracked files and commit with a message

git commit -a -m “Readme.md”

22 git reset –soft HEAD^

To undo the last commit and bring the file to the staging area.

// Undo last commit, keep changes in staging area

git reset –soft HEAD^

23 git reset –hard HEAD^

To undo the last commit and remove the file from the staging area as well(In case we went horribly wrong).

git reset –hard HEAD^

24. git reset –hard HEAD^^

To undo the last 2 commits and all changes.

git reset –hard HEAD^^

25. git remote add origin

These commands make a bookmark which signifies that this particular remote refers to this URL. This remote will be used to pull any content from the directory and push our local content to the global server.

git remote add origin https://github.com/madaan123/MyAlgorithms

26. git remote add <address>

To add new remotes to our local repository for a particular git address.

git remote add

27. git remove rm

To remove a remote from our local repository.

git remove rm

28. git push -u origin master

To push all the contents of our local repository that belong to the master branch to the server(Global repository).

git push -u origin master

29. git clone https://github.com/madaan123/MyAlgorithms

To clone or make a local copy of the global repository in your system (git clone command downloads the repository and creates a remote named origin which can be checked by the command – git remote -v).

git clone https://github.com/madaan123/MyAlgorithms

30. git branch Testing

To create a new branch named Testing.

git branch Testing

31.git branch

To see all the branches present and current branches that we are working on.

git branch

32. git checkout Testing

To switch to branch Testing from the master branch.

git checkout Testing

33. ls

To see directories and files in the current directory.

ls

34. ls -la

To see hidden directories and files within the current directory.

ls -la

35. git merge Testing

To merge the Testing branch with the master branch.

git merge Testing

36. git branch -d Testing

To delete the Testing branch.

git branch -d Testing

37. git checkout -b admin

To create a new branch admin and set it as the current branch.

git checkout -b admin

38. git branch -r

To look at all the remote branches.

git branch -r

39. git branch -D Testing

To forcefully delete a branch without making commits.

git branch -D Testing

40. git tag

To see the list of available tags.

git tag

41. git checkout v0.0.1

To set the current tag to v0.0.1.

git checkout v0.0.1

42. git tag -a v0.0.3 -m “version 0.0.3”

To create a new tag.

git tag -a v0.0.3 -m “version 0.0.3”

43. git push –tags

To push the tags to the remote repository.

git push –tags

44. git fetch

To fetch down any changes from the global repository to the current repository.

git fetch

45. git stash

To move staged files to the stash area which is present in the staging area.

git stash

46. git stash pop

To get back the files that are present in the stash area.

git stash pop

47. git stash clear

To clear the stash folder.

git stash clear

48. git rebase

Three tasks are performed by git rebase

  1. Move all changes to master which are not in origin/master to a temporary area.
  2. Run all origin master commits.
  3. Run all commits in the temporary area on top of our master one at a time, so it avoids merge commits.

git rebase

49.git help

Take help from the Git help section for different commands and other errors.
//Get help on Git Commands

git help

50. git –version

used to show the current version of Git

git –version

Conclusion

Git is an important tool for beginners and developers. Learning these 50+ essential Git commands helps you manage code, track changes, and work better with a team. By practicing Git regularly, you can work faster, avoid mistakes, and build projects with confidence.

git tutorial for beginnersgit commands

Get the Free DevOps Quick Reference (PDF)

Docker, CI/CD, YAML, and Git commands your team uses every day — condensed into one printable sheet.

DevOps bottlenecks slowing your team down?

Our DevOps Engineering service builds CI/CD pipelines, container orchestration, and infrastructure-as-code — so your team ships faster with fewer incidents.

  • CI/CD pipeline design and implementation
  • Docker and Kubernetes environment management
  • Infrastructure-as-code (Terraform, Ansible)
  • 24×7 pipeline monitoring and incident response
See Pricing Plans →

What our customers say

“Our CI/CD pipeline was a mess. CloudHouse rebuilt it from scratch in 2 weeks and deployments went from 2 hours to 8 minutes.”

James L.

Lead Developer

“They containerised our entire monolith. Deployment reliability went from 70% to 99.8%. Transformative work.”

Nadia C.

CTO

Frequently Asked Questions

Yes — 90% of fixes are done over a secure remote session in 15–30 minutes. Our technicians connect safely using industry-standard tools.

Need this done for you?

Explore all CloudHouse services

ERP, CRM, apps, servers, security and support from one team.

Learn more

Book your free 15-minute diagnosis

A certified technician will call you back within 15 minutes during business hours.

Share this article

Leave a Comment

Comments (0)

Loading comments...