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

Git Commands CheatSheet

This document provides a comprehensive guide to using Git commands for version control, including configuration, basic commands, branching, updates, inspection, undoing changes, and advanced techniques. It outlines essential commands such as 'git init', 'git commit', 'git merge', and 'git push', along with their functionalities. The document is aimed at freelance developers looking to enhance their Git skills.

Uploaded by

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

Git Commands CheatSheet

This document provides a comprehensive guide to using Git commands for version control, including configuration, basic commands, branching, updates, inspection, undoing changes, and advanced techniques. It outlines essential commands such as 'git init', 'git commit', 'git merge', and 'git push', along with their functionalities. The document is aimed at freelance developers looking to enhance their Git skills.

Uploaded by

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

FREELANCER

Git
Commands

@shadowctrl
www.shadowctrl.me
Freelance Developer
FREELANCER

Config

Set your alias with: `git config --global user.name


"shadowctrl"` to tag your commits.

Add your email with: `git config --global user.email


"[email protected]"` to identify yourself with your
commits.

@shadowctrl
www.shadowctrl.me
Freelance Developer
FREELANCER

Starting

git init - Kickstart a shiny new local repo!

git clone https://github.com/shadowctrl/shadowctrl


- Snag a copy of a repo and plop it into a fresh
directory!

@shadowctrl
www.shadowctrl.me
Freelance Developer
FREELANCER

Basics

git add: Stage a file for commit.

git commit: Save your staged changes.

git status: Check the status of tracked and untracked

files.

git diff: View differences in your working directory.

git diff --staged: Compare staged changes with the

last commit.

git reset . : Unstage files.

git reset --hard: Reset working directory to the last

commit.

@shadowctrl
www.shadowctrl.me
Freelance Developer
FREELANCER

Branching

git branch - Show me the branch party lineup!

git branch master - Roll out the red carpet for a shiny

new branch called 'master!'

git checkout main - Time to boogie on over to the

'main' branch!

git merge v1.2.1 - Let's bring the 'v1.2.1' branch into the

current branch dance-off!

git branch -d v1.2.1 - Say goodbye and delete the 'v1.2.1'

branch from the guest list!

@shadowctrl
www.shadowctrl.me
Freelance Developer
FREELANCER

Updates

git remote add [alias] [url]: Add a new remote

repository.

git fetch [alias]: Retrieve the latest changes from the

remote.

git pull [alias] [branch]: Fetch and merge updates

from a specific remote branch.

git push [alias] [branch]: Send changes to a remote

branch.

git push [alias] [branch] -u: Push branch and set it as

the upstream branch.

@shadowctrl
www.shadowctrl.me
Freelance Developer
FREELANCER

Inspect

git log - Your time machine to the commit past!


git log --decorate --all --graph - A snazzy visual
feast of your commit journey!
git show [commit] - Get the juicy details on any
commit you fancy!
git diff [commit1] [commit2] - A showdown between
two commits, highlighting their juicy differences!

@shadowctrl
www.shadowctrl.me
Freelance Developer
FREELANCER

undo

git revert [commit]: Creates a new commit that


ndoes changes from the specified commit.
git reset --hard [commit]: Resets the working
directory and staging area to the state of the specified
commit.
git clean -f: Removes all untracked files from the
workspace, keeping it tidy.

@shadowctrl
www.shadowctrl.me
Freelance Developer
FREELANCER

Advanced

git rebase [branch]: Refresh and stack commits on a


new base.
git cherry-pick [commit]: Select changes from a
commit to add to the current project.

@shadowctrl
www.shadowctrl.me
Freelance Developer

You might also like