Basic Git Commands

Help

Display a list of commands and helpful info.

git help

Get more info about a command.

git help <command>

Init

Initialize a new repository.

Use this when you are starting a new codebase or adding an existing one to a repository.

git init

Clone

Copy an existing repository.

This will set up your copy to push and pull from the remote.

Use this when you are starting from an existing project that already has a repo.

git clone <repository url>

Add

Stage files to commit.

git add .

Add all changes.

git add -A

Commit

Save the changes that are staged in HEAD.

Customize the message so you can make sense of the history.

git commit -m "<message>"

Diff

Get a formatted display of file changes.

git diff

https://en.wikipedia.org/wiki/Diff

Log

View history of changes in the branch.

git log

Git log

Push

Push your committed changes to the remote repository.

git push

Blame

See who changed each line in a file.

git blame <file>

Level
Topics