Basic GIT cheat-sheet

Basic GIT cheat-sheet

·

2 min read

Git is the free and open source distributed version control system(VCS) that's responsible for everything GitHub related that happens locally on our computer.

Git is the most powerful tool in modern development.

There are too many Git commands, some of them are listed below:

1. Git config

Get and set configuration variables that control all facets of how Git looks and operates.

Syntax:

Set the name:
$ git config --global user.name "User name"

Check the setting:
$ git config -list

2. Git Init

Configuring user information, initializing and cloning repositories

Syntax:

initialize an existing directory as a Git repository:
$ git init

retrieve an entire repository from a hosted location via URL:
git clone [url]

3. Git Add Command

Add file contents to the index.

Syntax:

Add a file to staging (Index) area:
$ git add Filename

Add all files of a repo to staging (Index) area:
$ git add*

4. Git diff

Track the changes that have not been staged:

Syntax:

Track the changes that have staged but not committed:
 $ git diff

Track the changes after committing a file:
$ git diff HEAD

5. Git Status

Display the state of the working directory and the staging area.

Syntax:
$ git status

6. Git Commit Command

Record changes to the repository.

Syntax:

Commit changes to repository
$ git commit

Commit changes with message
$ git commit -m "Commit Message"

7. Git show command

Git show command shows all objects

Syntax:
$ git show

8. Git Push Command

Update remote refs along with associated objects.

Syntax:

command to send the changes made on the master branch, to your remote repository.
$ git push [variable name] master

Command to push all the branches to the server repository.
$ git push --all

9. Git Pull Command

Fetch from and integrate with another repository or a local branch.

Syntax:

$ git pull URL

10.Git Log Command

Shows commit logs.

Syntax:

Display the most recent commits and the status of the head:
$ git log

Display the modified files with location:
$ git log -p