25 essential git commands
1. Git init
Initializes a new Git repository in the current directory.
For more information on initializing a repository, see this page.
Example:
2. Git commit
Records changes to the repository with a message describing the changes.
For more information on committing changes, see this page.
Example:
3. Git branch
Lists, creates, or deletes branches.
For more information on branching, see this page.
Example:
4. Git checkout
Switches branches or restores working tree files.
For more information on checking out branches, see this page.
Example:
5. Git merge
Merges changes from one branch into the current branch.
For more information on checkout, see this page.
Example:
6. Git pull
Fetches from and integrates with another repository or a local branch.
For more information on pulling changes, see this page.
Example:
7. Git remote
Manages set of tracked repositories.
For more information on adding a remote repository, see this page.
Example:
8. Git clone
Clones a repository into a new directory.
For more information on cloning a repository, see this page.
Example:
9. Git log
Shows the commit logs.
For more information on viewing commit history, see this page.
Example:
10. Git fetch
Downloads objects and refs from another repository.
For more information on fetching changes, see this page.
Example:
11. Git blame
Shows what revision and author last modified each line of a file.
For more information on using git blame
, see this page.
Example:
12. Git stash
Stashes changes in a dirty working directory away.
For more information on stashing changes, see this page.
Example:
13. Git tag
Creates, lists, deletes or verifies tags.
For more information on tagging commits, see this page.
Example:
14. Git cherry-pick
Applies the changes introduced by some existing commits.
For more information on cherry-picking, see this page.
Example:
15. Git rebase
Reapplies commits on top of another base tip.
For more information on rebasing, see this page.
Example:
16. Git bisect
Uses binary search to find the commit that introduced a bug.
For more information on using git bisect
, see this page.
Example:
17. Git worktree
Manages multiple working trees.
For more information on using git worktree
, see this page.
Example:
18. Git reflog
Records when the tips of branches and other references were updated in the local repository.
For more information on using git reflog
, see this page.
Example:
19. Git rerere
Records and reuses conflict resolutions.
For more information on using git rerere
, see this page.
Example:
20. Git submodule
Initializes, updates, or inspects submodules.
For more information on using submodules, see this page.
Example:
21. Git filter-branch
Rewrites branches.
For more information on using git filter-branch
, see this page.
Example:
22. Git update-index
Updates the index using the working directory content.
For more information on using git update-index
, see this page.
Example:
23. Git gc
Runs a garbage collection to optimize the repository.
For more information on running git gc
, see this page.
Example:
24. Git instaweb
Instantiates a web server with an interface into the local repository.
For more information on using git instaweb
, see this page.
Example:
25. Git submodule foreach
Evaluates a shell command in each checked out submodule.
For more information on using git submodule foreach
, see this page.
Example: