Git Command List

Git Command List


Git, a distributed version control system, is an essential tool for modern software development. This guide provides a comprehensive list of Git commands, categorized for easy understanding and quick reference.

Understanding Git Commands

Git commands are powerful tools for managing and tracking changes in software projects. They range from basic to advanced, catering to various needs in the software development lifecycle.

Basic Git Commands

1. git init

  • Initializes a new Git repository.

2. git clone [URL]

  • Clones a repository into a new directory.

3. git add [file]

  • Adds files to the staging area.

4. git commit -m “[message]”

  • Records file snapshots in the repository.

5. git status

  • Displays the state of the working directory and staging area.

6. git push [remote] [branch]

  • Updates the remote repository with local commits.

7. git pull [remote]

  • Fetches and merges changes from the remote server.

8. git branch

  • Lists, creates, or deletes branches.

9. git checkout [branch-name]

  • Switches branches or restores working tree files.

10. git merge [branch]

  • Merges one branch into another.

11. git diff

  • Shows file differences not yet staged.

12. git log

  • Displays commit logs.

Intermediate Git Commands

13. git stash

  • Stashes the changes in a dirty working directory.

14. git rebase [branch]

  • Applies changes from one branch to another.

15. git reset [file]

  • Unstages a file while retaining the changes in the working directory.

16. git rm [file]

  • Removes files from the working directory and the index.

17. git fetch [remote]

  • Downloads objects and refs from another repository.

18. git tag [tag-name]

  • Marks a specific point in history as important.

Advanced Git Commands

19. git rebase -i

  • Interactive rebasing.

20. git cherry-pick [commit]

  • Applies some commit changes to the current branch.

21. git bisect

  • Use binary search to find the commit that introduced a bug.

22. git revert [commit]

  • Reverts some existing commits.

23. git blame [file]

  • Shows what revision and author last modified each line of a file.

24. git remote

  • Manages a set of tracked repositories.

25. git gc

  • Cleans up unnecessary files and optimizes the local repository.

Housekeeping and Maintenance Commands

26. git clean

  • Removes untracked files from the working directory.

27. git fsck

  • Checks the integrity of the Git file system.

28. git reflog

  • Records when the tips of branches and other references were updated.

29. git prune

  • Removes objects no longer pointed to by any entity in any reachable branch.


This comprehensive list of Git commands provides a foundation for anyone looking to master Git for version control. Whether you’re a beginner or an experienced developer, understanding and effectively utilizing these commands is crucial for efficient and successful software development. Remember, practice and consistent use are key to becoming proficient in Git.


Hi, my name is Stephen Finchett. I have been a software engineer for over 30 years and worked on complex, business critical, multi-user systems for all of my career. For the last 15 years, I have been concentrating on web based solutions using the Microsoft Stack including ASP.Net, C#, TypeScript, SQL Server and running everything at scale within Kubernetes.