0% found this document useful (0 votes)
33 views

Git Commands You Should Know

The document summarizes common Git commands: 1) git init initializes a new local repository, git clone obtains a remote repository from GitHub, and git add stages files or all files for commit. 2) git commit takes a snapshot of the staged changes with a message, and git diff shows unstaged or staged differences between files and the latest version. 3) git status shows all uncommitted modified files, git log lists the version history, and git branch displays local branches.

Uploaded by

Santosh Pasi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Git Commands You Should Know

The document summarizes common Git commands: 1) git init initializes a new local repository, git clone obtains a remote repository from GitHub, and git add stages files or all files for commit. 2) git commit takes a snapshot of the staged changes with a message, and git diff shows unstaged or staged differences between files and the latest version. 3) git status shows all uncommitted modified files, git log lists the version history, and git branch displays local branches.

Uploaded by

Santosh Pasi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Git Commands

you should know


git init
This command is used to start a new repository.
Git creates a .git directory

$ git init [repository name]

git clone

This command is used to obtain a repository from

an existing gitHub repo.

$ git clone [repository URL]

linkedin.com/in/mittal-sachin/ instagram.com/sachinmittal2003/
git add
This command is used to add a file to the staging

area.

$ git add [file name]

git add .

This command is used to add all the files to the

staging area.

$ git add .

linkedin.com/in/mittal-sachin/ instagram.com/sachinmittal2003/
git commit
This command takes a snapshot of project's
currently staged changes.

$ git commit -m “[ meaningful message]”

git diff
This command shows the file differences which are

not yet staged.

$ git diff

linkedin.com/in/mittal-sachin/ instagram.com/sachinmittal2003/
git diff –staged
This command shows the differences between files

in the staging area and latest version present.

$ git diff -staged

git status
This command shows all the modified files which

are not committed.

$ git status

linkedin.com/in/mittal-sachin/ instagram.com/sachinmittal2003/
git log
This command shows the list of version history.

$ git log

git branch
This command shows all the branches of repo.

$ git branch

linkedin.com/in/mittal-sachin/ instagram.com/sachinmittal2003/
git checkout
This command is used to switch between branches.

$ git checkout [branch name]

To create new branch and switch to that.

$ git checkout -b [branch name]

linkedin.com/in/mittal-sachin/ instagram.com/sachinmittal2003/
git push
This command sends all committed changes to your

repo.

$ git push origin master

git merge
This command shows all the branches of repo.

$ git merge [branch name]

linkedin.com/in/mittal-sachin/ instagram.com/sachinmittal2003/
git pull
This command fetch and merge changes.

$ git pull [Repository Link]

git stash
This command temporarily stores all the modified

tracked files.

$ git stash save

linkedin.com/in/mittal-sachin/ instagram.com/sachinmittal2003/
Thanks for

Reading

You might also like