Sitemap
sivesh kumar

sivesh kumar

Technical Leader ( MERN / MEAN )

GIT Cheat Sheet

3 min readJan 14, 2024

--

What is Git?

Git is a version control system that helps you track changes in your project’s code over time. It allows multiple people to collaborate on the same project without overwriting each other’s work. Git is especially useful for managing code and other text files.

Press enter or click to view image in full size

Setting up Git

#Configure User Information
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Creating and Cloning Repositories

git init #Create a new Git repository
git clone <repository_url> #Clone an existing repository

Basic Commands

git status #Check the status of your repository
git add <file(s)> #Add changes to the staging area
git commit -m "Your commit message" #Commit changes
git log #View commit history
git reset --soft HEAD^ #Undo last commit (soft)
git reset --hard HEAD^ #Undo last commit (hard)

Branching and Merging

git branch <branch_name> #Create a new branch
git checkout <branch_name> #Switch to a branch
git checkout -b <branch_name> #Create and switch to a new branch
git merge <branch_name> #Merge branches
git branch -d <branch_name> #Delete a branch

Remote Repositories

git remote add origin <repository_url> #Add a remote repository
git push -u origin <branch_name> #Push changes to a remote repository
git pull origin <branch_name> #Pull changes from a remote repository

Miscellaneous

git diff <commit_hash1> <commit_hash2> #See changes between commits
git show --name-only #Show files changed in the last commit
git checkout -- <file(s)> #Discard changes in working directory

If you’ve made it till here, thanks for giving this a read, have a great day! :)

Get sivesh kumar’s stories in your inbox

Join Medium for free to get updates from this writer.

Follow for More

https://www.linkedin.com/in/sivesh-kumar/
https://siveshkumar.com
https://medium.com/@sivesh-kumar
https://github.com/sivesh2000
https://www.instagram.com/
codewithsivesh/
https://whatsapp.com/channel/
0029VaIonGZDTkJwCGrAXT0D

--

--

sivesh kumar
sivesh kumar

Written by sivesh kumar

Technical Leader ( MERN / MEAN )