0% found this document useful (0 votes)
110 views5 pages

Git Cheat Sheet

This document provides a quick reference to common Git commands and their usage, including commands for initializing a repository, tracking changes, committing files, branching, merging, and interacting with remote repositories. It lists commands for setting up configuration, viewing the status and differences of files, adding and committing files, creating and switching branches, merging branches, deleting branches, viewing logs and history, and cloning or pulling from remote repositories.

Uploaded by

Ishu Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views5 pages

Git Cheat Sheet

This document provides a quick reference to common Git commands and their usage, including commands for initializing a repository, tracking changes, committing files, branching, merging, and interacting with remote repositories. It lists commands for setting up configuration, viewing the status and differences of files, adding and committing files, creating and switching branches, merging branches, deleting branches, viewing logs and history, and cloning or pulling from remote repositories.

Uploaded by

Ishu Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

GIT CHEAT SHEET

This document provides a quick reference to a concise set of commands from various operations in Git, with their
usage for further practice.
$ git init [project-name]
Creates a new local repository with the specified argument

$ git status

Lists all new or modified files to be committed

$ git config --global user.name "[user-name]“

Defines the name you want associated with your commit transactions

$ git config --global user.email "[user-email-address]"

Defines the email address you want associated with your commit transactions

$ git config --global color.ui auto

Turns on colorization of command line output

$ git add [file]

Prepares the file for commit by logically moving it to the staged area

$ git ls-files --stage

Lists all the files in the staged area

$ git commit -m "[commit message]"

Adds the staged files permanently in version history

1|Page ©Simplilearn. All rights reserved


$ git diff

Shows unstaged file differences

$ git diff --staged

Shows file differences between staging and the last file version

$ git branch

Lists all branches in the current local repository

$ git branch [branch-name]

Creates a new branch

$ git checkout [branch-name]

Switches to the specified branch and updates the working directory

$ git merge [branch-name]

Combines the specified branch’s history into the current branch

$ git branch -d [branch-name]

Deletes the specified branch

$ git rm [file]

Deletes the file from the working directory and the staging area

2|Page ©Simplilearn. All rights reserved


$ git rm --cached [file]

Removes the file from version control but retains the file locally

$ git log

Lists version history for the current branch

$ git log --oneline

Lists version history in one line for the current branch

$ git log –oneline –decorate --graph

Lists version history in one line, decorated in graphical form for the current branch

$ git push [alias] [branch]

Uploads all local branch commits to remote repository

$ git pull
Downloads from remote repository and incorporates changes

$ git stash

Temporarily stores all modified tracked files

$ git clone [repository-url]

Clones an existing repository

3|Page ©Simplilearn. All rights reserved


$ git rebase [branch]

Rebases your current HEAD onto [branch]

4|Page ©Simplilearn. All rights reserved

You might also like