GIT Cheat Sheet
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.
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 repositoryBasic 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 branchRemote 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 repositoryMiscellaneous
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 directoryIf 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
codewithsivesh/
0029VaIonGZDTkJwCGrAXT0D








