SlideShare a Scribd company logo
2
Most read
4
Most read
6
Most read
git Most Used Commands
GIT Commands
Commands Description
git --version To check version of Git installed.
git config--system user.name <username> System level (All users on the system)
git config --global user.name <username> Global level (for all the projects of a user)
git config --local user.name <username> Local (default and specific for a repository)
git config --global core.excludesfile
%USERPROFILE%.gitignore
. gitignore files should have the list of files to be
ignored.
git add . To add new and modified but not deleted.
git add -u To add modified and deleted but not new
files/directories
GIT Commands
Commands Description
git Add -u To add modified and deleted and new
files/directories.
git commit --am “<message to commit> Creates a commit and adds files to staging.
git commit --m “<message to commit> Creates a commit from staging. Assumes files already
added to staging
git init Creates .git subfolder in the project, which contains all
necessary metadata
git remote add origin
https://github.com/Viyaan/<repository>.git
To add a new repo
git push origin <source_branch>:<destination branch> Actual syntax but the below syntax is enough
git push -u origin <source branch name> push your changes to selected branch, since source
and destination will always be same. It’s enough to
mention only source branch.
GIT Commands
Commands Description
git status gives status of tracked and untracked changes in your
local repository.
git branch list all available branches in local system.
git branch -r list all branches in repository
git branch <new branch name> create a new branch
git checkout <branch name> switch to another branch
git checkout -b <branch name> creates and switches to another branch
git merge <branch name> Merges specified branch into current.
GIT Commands
Commands Description
git rm <file name> To delete a file, you must commit and push after
deleting.
git diff <file-name> To see difference between uncommitted version to
remote version of a file.
git diff shows the changes you have done in your existing file
(compare different versions of your files)
git log Prints log of past commits
git log --oneline Prints log of past commits in one line.
git tag list all tags.
git tag <tag name> create a tag. You need to push after new tag is
created.
GIT Commands
Commands Description
git branch -D <branch name> To delete a branch. You must push after delete
command.
git branch -d <branch name> Same as above but this time it will ask for
confirmation If its not merged.
git push origin :<destination branch> After deleting you must push and while pushing you
should mention the destination branch. Destination
branch is the branch u deleted.
git tag -d <tag name> To delete a tag, use small d and not capital.
git clone <clone url> To clone a repository
git fetch origin To fetch new data from remote repository. But it
doesn’t integrate any of those new data into your
working files.
GIT Commands
Commands Description
git pull pull not only downloads new data; it also
directly integrates it into your current working copy
files.
git remote add <remote-name> <remote-url> To add a new remote, use the git remote
add command on the terminal, in the directory your
repository is stored at.
git remote show To see number of remote repositories available.
git stash Git stash temporarily shelves or stashes changes made
to your working copy so you can work on something
else, and come back and re-apply them later.
git stash save <stash name> To save list of uncommitted changes in stash.
git stash list List of stashes.
git stash pop Apply changes which were stashed.
GIT Commands
Commands Description
git commit --amend Modify the most recent commit
git commit --amend -m "an updated commit message" Modify the most recent commit message
git rev -parse HEAD Specify where head pointing too.
Reset
• git reset --soft <commit id>
• git reset --mixed <commit id>
• The difference between --mixed and --soft is whether or not your index is also modified. So, if we're on branch master
with this series of commits:
• - A - B - C (master)
• HEADpoints to C and the index matches C.
• When we run git reset --soft B, master (and thus HEAD) now points to B, but the index still has the changes from C; git
status will show them as staged. So if we run git commit at this point, we'll get a new commit with the same changes as C.
• ________________________________________
• Okay, so starting from here again:
• - A - B - C (master)
• Now let's do git reset --mixed B. (Note: --mixed is the default option). Once again, master and HEAD point to B, but this
time the index is also modified to match B. If we run git commit at this point, nothing will happen since the index matches
HEAD. We still have the changes in the working directory, but since they're not in the index, git status shows them as
unstaged. To commit them, you would git add and then commit as usual.
• ________________________________________
• And finally, --hard is the same as --mixed (it changes your HEAD and index), except that --hard also modifies your
working directory. If we're at C and run git reset --hard B, then the changes added in C, as well as any uncommitted
changes you have, will be removed, and the files in your working copy will match commit B. Since you can permanently
lose changes this way, you should always run git status before doing a hard reset to make sure your working directory is
clean or that you're okay with losing your uncommitted changes.
Reset
• git reset --hard <commit id>
resets the HEAD to any commit mentioned in command. And throws away all
your changes which is made after the commit corresponding to the commit id.

More Related Content

PPT
Git basic
PDF
git and github
PPTX
GitHub Basics - Derek Bable
PPTX
Github basics
PPTX
Git basics to advance with diagrams
PDF
Git real slides
PDF
Learning git
Git basic
git and github
GitHub Basics - Derek Bable
Github basics
Git basics to advance with diagrams
Git real slides
Learning git

What's hot (20)

PPTX
Git - Basic Crash Course
PDF
Git training v10
PPTX
Git in 10 minutes
PPTX
Git 101 for Beginners
PPTX
Introduction git
KEY
Introduction to Git
PPTX
Intro to git and git hub
PDF
Git Introduction Tutorial
PDF
Github - Git Training Slides: Foundations
PDF
Git basics for beginners
KEY
The everyday developer's guide to version control with Git
PDF
Git basics
PDF
Starting with Git & GitHub
KEY
Introduction To Git
PDF
Git and git flow
PPTX
PPTX
Git One Day Training Notes
PDF
Introduction to Git
PDF
Git Rebase vs Merge
ODP
Git vs svn
Git - Basic Crash Course
Git training v10
Git in 10 minutes
Git 101 for Beginners
Introduction git
Introduction to Git
Intro to git and git hub
Git Introduction Tutorial
Github - Git Training Slides: Foundations
Git basics for beginners
The everyday developer's guide to version control with Git
Git basics
Starting with Git & GitHub
Introduction To Git
Git and git flow
Git One Day Training Notes
Introduction to Git
Git Rebase vs Merge
Git vs svn
Ad

Similar to Git commands (20)

PDF
test
PDF
Git cheat-sheet-education
PDF
Techmoneyguide
PDF
Git cheat-sheet-education
PDF
SVN 2 Git
PDF
Atlassian git cheatsheet
PDF
Git of every day
PDF
Github git-cheat-sheet
PPSX
Advanced Web Development in PHP - Code Versioning and Branching with Git
PDF
Git and github 101
PPTX
Git Memento of basic commands
PDF
Github git-cheat-sheet
PDF
Github git-cheat-sheet
PDF
Github git-cheat-sheet
PDF
Github git-cheat-sheet
PPTX
Hacktoberfest intro to Git and GitHub
PDF
Github git-cheat-sheet
PPTX
Git hub abduallah abu nada
PPTX
Learning Basic GIT Cmd
PDF
Essential Git and Github commands
test
Git cheat-sheet-education
Techmoneyguide
Git cheat-sheet-education
SVN 2 Git
Atlassian git cheatsheet
Git of every day
Github git-cheat-sheet
Advanced Web Development in PHP - Code Versioning and Branching with Git
Git and github 101
Git Memento of basic commands
Github git-cheat-sheet
Github git-cheat-sheet
Github git-cheat-sheet
Github git-cheat-sheet
Hacktoberfest intro to Git and GitHub
Github git-cheat-sheet
Git hub abduallah abu nada
Learning Basic GIT Cmd
Essential Git and Github commands
Ad

More from Viyaan Jhiingade (7)

PPTX
Rate limiting
PPTX
Introduction to Scala
PPTX
PPTX
Rest Webservice
PPTX
PPTX
Jenkins CI
PPTX
Kafka RealTime Streaming
Rate limiting
Introduction to Scala
Rest Webservice
Jenkins CI
Kafka RealTime Streaming

Recently uploaded (20)

PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
Cost to Outsource Software Development in 2025
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Complete Guide to Website Development in Malaysia for SMEs
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
CHAPTER 2 - PM Management and IT Context
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Nekopoi APK 2025 free lastest update
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
Why Generative AI is the Future of Content, Code & Creativity?
AutoCAD Professional Crack 2025 With License Key
17 Powerful Integrations Your Next-Gen MLM Software Needs
Cost to Outsource Software Development in 2025
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Complete Guide to Website Development in Malaysia for SMEs
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Designing Intelligence for the Shop Floor.pdf
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
CHAPTER 2 - PM Management and IT Context
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Navsoft: AI-Powered Business Solutions & Custom Software Development
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Nekopoi APK 2025 free lastest update
Autodesk AutoCAD Crack Free Download 2025
Odoo Companies in India – Driving Business Transformation.pdf
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free

Git commands

  • 1. git Most Used Commands
  • 2. GIT Commands Commands Description git --version To check version of Git installed. git config--system user.name <username> System level (All users on the system) git config --global user.name <username> Global level (for all the projects of a user) git config --local user.name <username> Local (default and specific for a repository) git config --global core.excludesfile %USERPROFILE%.gitignore . gitignore files should have the list of files to be ignored. git add . To add new and modified but not deleted. git add -u To add modified and deleted but not new files/directories
  • 3. GIT Commands Commands Description git Add -u To add modified and deleted and new files/directories. git commit --am “<message to commit> Creates a commit and adds files to staging. git commit --m “<message to commit> Creates a commit from staging. Assumes files already added to staging git init Creates .git subfolder in the project, which contains all necessary metadata git remote add origin https://github.com/Viyaan/<repository>.git To add a new repo git push origin <source_branch>:<destination branch> Actual syntax but the below syntax is enough git push -u origin <source branch name> push your changes to selected branch, since source and destination will always be same. It’s enough to mention only source branch.
  • 4. GIT Commands Commands Description git status gives status of tracked and untracked changes in your local repository. git branch list all available branches in local system. git branch -r list all branches in repository git branch <new branch name> create a new branch git checkout <branch name> switch to another branch git checkout -b <branch name> creates and switches to another branch git merge <branch name> Merges specified branch into current.
  • 5. GIT Commands Commands Description git rm <file name> To delete a file, you must commit and push after deleting. git diff <file-name> To see difference between uncommitted version to remote version of a file. git diff shows the changes you have done in your existing file (compare different versions of your files) git log Prints log of past commits git log --oneline Prints log of past commits in one line. git tag list all tags. git tag <tag name> create a tag. You need to push after new tag is created.
  • 6. GIT Commands Commands Description git branch -D <branch name> To delete a branch. You must push after delete command. git branch -d <branch name> Same as above but this time it will ask for confirmation If its not merged. git push origin :<destination branch> After deleting you must push and while pushing you should mention the destination branch. Destination branch is the branch u deleted. git tag -d <tag name> To delete a tag, use small d and not capital. git clone <clone url> To clone a repository git fetch origin To fetch new data from remote repository. But it doesn’t integrate any of those new data into your working files.
  • 7. GIT Commands Commands Description git pull pull not only downloads new data; it also directly integrates it into your current working copy files. git remote add <remote-name> <remote-url> To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at. git remote show To see number of remote repositories available. git stash Git stash temporarily shelves or stashes changes made to your working copy so you can work on something else, and come back and re-apply them later. git stash save <stash name> To save list of uncommitted changes in stash. git stash list List of stashes. git stash pop Apply changes which were stashed.
  • 8. GIT Commands Commands Description git commit --amend Modify the most recent commit git commit --amend -m "an updated commit message" Modify the most recent commit message git rev -parse HEAD Specify where head pointing too.
  • 9. Reset • git reset --soft <commit id> • git reset --mixed <commit id> • The difference between --mixed and --soft is whether or not your index is also modified. So, if we're on branch master with this series of commits: • - A - B - C (master) • HEADpoints to C and the index matches C. • When we run git reset --soft B, master (and thus HEAD) now points to B, but the index still has the changes from C; git status will show them as staged. So if we run git commit at this point, we'll get a new commit with the same changes as C. • ________________________________________ • Okay, so starting from here again: • - A - B - C (master) • Now let's do git reset --mixed B. (Note: --mixed is the default option). Once again, master and HEAD point to B, but this time the index is also modified to match B. If we run git commit at this point, nothing will happen since the index matches HEAD. We still have the changes in the working directory, but since they're not in the index, git status shows them as unstaged. To commit them, you would git add and then commit as usual. • ________________________________________ • And finally, --hard is the same as --mixed (it changes your HEAD and index), except that --hard also modifies your working directory. If we're at C and run git reset --hard B, then the changes added in C, as well as any uncommitted changes you have, will be removed, and the files in your working copy will match commit B. Since you can permanently lose changes this way, you should always run git status before doing a hard reset to make sure your working directory is clean or that you're okay with losing your uncommitted changes.
  • 10. Reset • git reset --hard <commit id> resets the HEAD to any commit mentioned in command. And throws away all your changes which is made after the commit corresponding to the commit id.