Skip to content

This Git Cheat Sheet includes the most commonly used Git commands. Perfect for quick reference while coding or learning Git.

Notifications You must be signed in to change notification settings

krissphi/git_cheat_sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 

Repository files navigation

Git Cheat Sheet

Git is a free and open-source tool that helps you manage changes to your code on your own computer. It’s the system that makes everything you do with GitHub possible. This cheat sheet lists the most important Git commands you’ll use often, so you can easily look them up when you need them.

Install Git

Windows
Download and Install Git from : https://git-scm.com/downloads

Linux

sudo apt install git 

MacOS

brew install git

Check Git version after installation

git --version

More details at : https://git-scm.com

Settup Account

git config --global user.name "[your name]"
git config --global user.email "youremail@example.com"

Check Account

git config --list

Start Project with Git

Upload Project to Github
Create new repository first in github, and then in project terminal

git init
git add .
git commit -m "Initial commit"
git remote add origin <url-repo>
git branch -m main
git push -u origin main

Download / Copy / Clone a Project

git clone <url>

Change Remote

git remote set-url origin <new-url>
git remote -v

Branch

Create a new branch

git branch <branch-name>

Get list of all branch

git branch

Change to branch

git checkout <branch-name>

Merge branch

git merge <branch-name>

Delete local branch

git branch -d <branch>

Commit to Git

git init
git add <file-name> //to add a file
git add . //to add all changes
git commit -m "<descriptive-message>"
git push origin [branch-name]

Update current branch

git fetch [branch-name] //Fetch other branch without merge
git pull [branch-name] //Fecth and merge 

Undo commit

git reset --soft HEAD~1 //Undo last commit (keep changes)
git reset --hard HEAD~1 //Undo and discard changes

Additional

Check Log

git log

Check diff

git diff

Ignoring files
create file .gitignore, and then add this

/logs *
!logs/.gitkeep
pattern*/
/tmp
*.swp
*.notes
EOF

cheats sheet by github :
https://education.github.com/git-cheat-sheet-education.pdf
https://about.gitlab.com/images/press/git-cheat-sheet.pdf

About

This Git Cheat Sheet includes the most commonly used Git commands. Perfect for quick reference while coding or learning Git.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published