Git Commands

Basic Git commands you need to know.

Git Commands

Basic Commands

git init

The git init command is used to initialize a new Git repository.

git init

git clone

The git clone command is used to clone a remote repository.

git clone <url>

git add

The git add command is used to add files to the staging area.

git add <file>

git commit

The git commit command is used to commit staged files to the repository.

git commit -m "commit message"

git status

The git status command is used to display the status of the repository.

git status

git log

The git log command is used to display the commit history of the repository.

git log

git diff

The git diff command is used to display the changes between commits, commit and working tree, etc.

git diff

git branch

The git branch command is used to list, create, or delete branches.

git branch

git checkout

The git checkout command is used to switch branches or restore working tree files.

git checkout <branch>

git merge

The git merge command is used to merge branches.

git merge <branch>

git pull

The git pull command is used to fetch and merge changes from the remote repository.

git pull

git push

The git push command is used to push local commits to the remote repository.

git push

git remote

The git remote command is used to manage remote repositories.

git remote

git rm

The git rm command is used to remove files from the working tree and the index.

git rm <file>

git mv

The git mv command is used to move or rename files.

git mv <file>

git reset

The git reset command is used to reset the current HEAD to the specified state.

git reset <file>

git stash

The git stash command is used to temporarily store changes that you don’t want to commit immediately.

git stash

git tag

The git tag command is used to create, list, delete, or verify a tag object signed with GPG.

git tag

git show

The git show command is used to show various types of objects.

git show

git fetch

The git fetch command is used to download objects and refs from another repository.

git fetch

git grep

The git grep command is used to print lines matching a pattern.

git grep

git ls-tree

The git ls-tree command is used to list the contents of a tree object.

git ls-tree

git cat-file

The git cat-file command is used to provide content or type and size information for repository objects.

git cat-file

git rev-parse

The git rev-parse command is used to pick out and massage parameters.

git rev-parse

git show-ref

The git show-ref command is used to list references in a local repository.

git show-ref