Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views50 pages

Git Commands Handbook

This document provides a comprehensive list of essential Git commands along with their descriptions. Each command is presented with a brief explanation of its function, such as initializing a repository, cloning, adding files, and managing branches. It serves as a quick reference guide for users to navigate Git functionalities effectively.

Uploaded by

Gopal B
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)
15 views50 pages

Git Commands Handbook

This document provides a comprehensive list of essential Git commands along with their descriptions. Each command is presented with a brief explanation of its function, such as initializing a repository, cloning, adding files, and managing branches. It serves as a quick reference guide for users to navigate Git functionalities effectively.

Uploaded by

Gopal B
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/ 50

GIT

COMMANDS
EVERYTHING YOU NEED
git init
git init

Initialize a new Git repository

AFRIN AHAMED
git clone
git clone
https://github.com/username/repository.git
Clone a repository into a new
directory

AFRIN AHAMED
git add
git add README.md

Add file contents to the index

AFRIN AHAMED
git mv
git mv file_from file_to

Move or rename a file, a directory, or


a symlink

AFRIN AHAMED
git rm
git rm filename

Remove files from the working tree


and from the index

AFRIN AHAMED
git commit
git commit -m "Commit
message"
Record changes to the repository

AFRIN AHAMED
git status
git status

Show the working tree status

AFRIN AHAMED
git branch
git branch -a

List, create, or delete branches

AFRIN AHAMED
git checkout
git checkout branch_name

Switch branches or restore working


tree files

AFRIN AHAMED
git merge
git merge feature

Join two or more development


histories together

AFRIN AHAMED
git rebase
git rebase master

Reapply commits on top of another


base tip

AFRIN AHAMED
git tag
git tag -a v1.4 -m "my
version 1.4"
Create, list, delete or verify a tag
object signed with GPG

AFRIN AHAMED
git fetch
git fetch origin

Download objects and refs from


another repository

AFRIN AHAMED
git pull
git pull origin master

Fetch from and integrate with


another repository or a local branch

AFRIN AHAMED
git push
git push origin master

Update remote refs along with


associated objects

AFRIN AHAMED
git stash
git stash save "work in
progress"
Stash the changes in a dirty working
directory away

AFRIN AHAMED
git log
git log --oneline

Show commit logs

AFRIN AHAMED
git diff
git diff HEAD~1

Show changes between commits,


commit and working tree, etc

AFRIN AHAMED
git reset
git reset --hard HEAD~1

Reset current HEAD to the specified


state

AFRIN AHAMED
git remote
git remote -v

Manage set of tracked repositories

AFRIN AHAMED
git submodule
git submodule update --init

Initialize, update or inspect


submodules

AFRIN AHAMED
git bisect
git bisect start

Use binary search to find the commit


that introduced a bug

AFRIN AHAMED
git grep
git grep "foo()"

Print lines matching a pattern

AFRIN AHAMED
git cherry-pick
git cherry-pick 4a20915

Apply the changes introduced by


some existing commits

AFRIN AHAMED
git revert
git revert 3e6b2a1

Revert some existing commits

AFRIN AHAMED
git archive
git archive --format=tar
master
Create an archive of files from a
named tree

AFRIN AHAMED
git clean
git clean -f

Remove untracked files from the


working tree

AFRIN AHAMED
git describe
git describe --tags HEAD

Show the most recent tag that is


reachable from a commit

AFRIN AHAMED
git show
git show v1.2.1

Show various types of objects

AFRIN AHAMED
git config
git config user.name "John
Doe"
Get and set repository or global
options

AFRIN AHAMED
git ls-tree
git ls-tree HEAD

List the contents of a tree object

AFRIN AHAMED
git cat-file
git cat-file -p 2b5bfdf

Provide content or type and size


information for repository objects

AFRIN AHAMED
git merge-tree
git merge-tree
4b825dc642cb6eb9a060e54
bf8d69288fbee4904
Show the changes between two tree
objects

AFRIN AHAMED
git verify-tag
git verify-tag v1.4.0

Verify the GPG signature of a tag

AFRIN AHAMED
git blame
git blame README.md

Show what revision and author last


modified each line of a file

AFRIN AHAMED
git rev-parse
git rev-parse HEAD

Parse revision (or other objects)


identifiers

AFRIN AHAMED
git shortlog
git shortlog

Summarize 'git log' output

AFRIN AHAMED
git show-ref
git show-ref --heads

List references in a local repository

AFRIN AHAMED
git pack-refs
git pack-refs --all

Pack heads and tags for efficient


repository access

AFRIN AHAMED
git filter-branch
git filter-branch --env-filter

Rewrite branches

AFRIN AHAMED
git reflog
git reflog show master

Show reflog information

AFRIN AHAMED
git rebase --
interactive
git rebase --interactive
HEAD~3
Rebase commits interactively

AFRIN AHAMED
git remote
rename
git remote rename origin
upstream
Rename a remote

AFRIN AHAMED
git bundle
git bundle create repo.bundle
HEAD master
Move objects and refs by archive

AFRIN AHAMED
git fsck
git fsck

Verifies the connectivity and validity


of the objects in the database

AFRIN AHAMED
git prune
git prune

Prune all unreachable objects from


the object database

AFRIN AHAMED
git count-objects
git count-objects -vH

Count unpacked number of objects


and their disk consumption

AFRIN AHAMED
git repack
git repack -a -d

Pack unpacked objects in a


repository

AFRIN AHAMED
git replace
git replace
5b5b025afb0b4c913b4c338a
42934a3863bf3644
Replace an object with another
object

AFRIN AHAMED

You might also like