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

Mega Cheat Sheet: Save For Later

This document provides a cheat sheet for common Git commands organized into 9 sections: 1) Setup and initialization commands like git config and git init 2) Stages and snapshots commands like git add, git commit, and git diff 3) Branch and merge commands like git branch, git checkout, and git merge 4) Inspect and compare commands like git log and git diff 5) Rewrite history commands like git rebase and git reset 6) Ignoring patterns using .gitignore and git config 7) Temporary commits using git stash 8) Sharing and updating repositories with commands like git remote, git fetch, and git push 9) Tracking path changes with git rm and git mv

Uploaded by

Nakul Amate
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)
64 views

Mega Cheat Sheet: Save For Later

This document provides a cheat sheet for common Git commands organized into 9 sections: 1) Setup and initialization commands like git config and git init 2) Stages and snapshots commands like git add, git commit, and git diff 3) Branch and merge commands like git branch, git checkout, and git merge 4) Inspect and compare commands like git log and git diff 5) Rewrite history commands like git rebase and git reset 6) Ignoring patterns using .gitignore and git config 7) Temporary commits using git stash 8) Sharing and updating repositories with commands like git remote, git fetch, and git push 9) Tracking path changes with git rm and git mv

Uploaded by

Nakul Amate
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/ 10

MEGA

CHEAT
SHEET
Save for later
or swipe left
1.SETUP & INIT
git config-global username [Firstname
Lastname]
>> set name that is identifiable for credit when
reviewing version history
git config-global useremail
[vallid email]
>> set an email address that will be associated
with each history maker
git config-global color UI auto
>> set automatic command line for git for easy
writing
git init
>> initialize an existing repository as a git
repository
1/8
git clone [URL]
>> retrieve an entire repository from a hosted
location via URL

2. STAGES & SNAPSHOTS


git branch
>> list your branch. a will appear next to the
currently active branch
git branch [branch-name]
>> create a new branch at current commit
git checkout
>> switch new another branch and check it out
git merge
>> merge the specified branches history into the
current one

2/8
git diff-staged
>> show modified files in working directory
staged for your next committed
git commit [descriptive message]
>> commit your staged content as a new commit
snapshot

3. BRANCH & MERGE


git branch
>> show modified files in working directory
staged for your next comment
git add [file]
>> add the file as it looks wow to your next
commit

3/8
git reset [file]
>> unstage a file while remaining the changes in
the working directory
git diff
>> diff of what is staged but not yet committed

4. INSPECT & COMPARE


git log
>> show all commits in the current branch history
git log branch_B . . . branch_A
>> show all commits that are in branch A that are
not on branch B
git log -- stat-M
>> show all commit logs with an indication of any
path that move

4/8
5. REWRITE HISTORY
git rebase [branch]
>> apply any commits to the current branch
ahead of specified one
git reset-hard [commit]
>> show all commits that are in branch A that are
not on branch B

6. IGNORING PATTERNS
logs/ notes/ pattern
>> save file with desired patterns as git ignore
with either direct string matches
git config-global core excludes file [file]
>> system-wide ignore pattern for all local
repositories
5/8
7. TEMPORARY COMMITS
git stash
>> save modified and staged changes git
git stash list
>> list stack order of stashed file changes
git stash pop
>> write working from top of stash stack
git log -- follow [life]
>> show the commits that changed file even
across renames
git show [SHA]
>> show any object in git in human readable
format

6/8
8. SHARE & UPDATE
git remote add [alias] [URL]
>> add git as an alias
git fetch [alias]
>> fetch down all the branches from that git
remote
git merge [alias]/[branch]
>> merge a remote branch into your current
branch to bring it up to date
git push [alias] [branch]
>> transmit local branch commit to the remote
repository branch
git pull
>> fetch and merge any commit from the
tracking remote
7/8
9. TRACKING PATH CHANGE
git rm [file]
>> delete the file from project and stage
removal for commit
git mv [existing path] [new path]
>> change the existing file path and stage the
move

8/8
Turn on post notifications

FOLLOW
@NamasteDevOfficial
on
for more exciting updates!

don't feel shy spread


knowledge to everyone

You might also like