A Cheatsheet For Git
Read Time:2 Minute, 0 Second

Here is a cheat sheet for some commonly used Git commands:
Setup
- git config –global user.name “Your Name”: Set your name to be used as the commit author
- git config –global user.email “[email protected]“: Set your email to be used as the commit author
Creating Repositories
- git init: Initialize a new Git repository
-
git clone
<repository>
: Clone an existing repository
Making Changes
- git status: Check the status of your repository
-
git add
<file>
: Add a file to the staging area - git add . : Add all modified and new files to the staging area
- git commit -m “message”: Commit changes with a message
-
git reset HEAD
<file>
: Remove a file from the staging area
Viewing History
- git log: View the commit history
- git diff: View changes that have not been staged
- git diff –staged: View changes that have been staged
Working with Remotes
-
git remote add
<name> <url>
: Add a remote repository -
git push
<name> <branch>
: Push changes to a remote repository -
git pull
<name> <branch>
: Pull changes from a remote repository
Branching
- git branch: List all branches
-
git branch
<name>
: Create a new branch -
git branch -d
<name>
: Delete a branch -
git checkout
<name>
: Switch to a branch
Merging
-
git merge
<branch>
: Merge a branch into the current branch
Stashing Changes
- git stash: Stash changes
- git stash list: View a list of stashes
- git stash apply: Apply the latest stash
- git stash drop: Discard the latest stash
Tagging
-
git tag
<tagname>
: Create a new tag -
git tag -a
<tagname>
-m “message”: Create a new tag with a message -
git tag -d
<tagname>
: Delete a tag - git push –tags: Push tags to the remote repository
Reverting Changes
- git revert HEAD: Revert the last commit
-
git revert
<commit>
: Revert a specific commit
Resetting
- git reset HEAD: Reset the staging area to the last commit
- git reset –hard HEAD: Reset the staging area and working directory to the last commit
-
git reset –hard
<commit>
: Reset the staging area and working directory to a specific commit
Aliases
-
git config –global alias.
<alias_name> <git_command>
: Create aliases for commonly used commands
Source: https://dev.to/arafat4693/a-cheatsheet-for-git-37n5

Tag Cloud
Java Java Logical Programs OTP Generation in Java python Recursion youtube video ASCII Upper and Lower Case blockchain javascript graph learn to code software development Successful Software Engineers breadth first search Java Array Programs Java Programs Uncategorized android ios programming kotlin web-development django data sql cybersecurity database swiftui serverless aws swift rust react background-position gradients loader mask grid nth-child pseudo elements indieweb WordPress Print Array without brackets C++ factorial Java String Programs Final Keyword Static Variable Axie Infinity Cryptokitties NFT games tool inserting MISC Tips Codes python code python projects python3 system info python project Bigginers How to Do Integrations Payment Gateways PHP checkout page in php Implement stripe payment gateway in Step by step in PHP integrate stripe gatway in php mysql payment gateway integration in php step by step payment gateway integration in php step by step with source code payment gateway integration in website PHP Integrate Stripe Payment Gateway Tutorial PHP shopping cart checkout code shopping cart in php stripe php checkout PHP/MySQL/JSON best international payment gateway does google pay accept international payments how to accept international payments in india paytm payment gateway razorpay codeigniter github razorpay custom checkout github razorpay get payment details razorpay integration in codeigniter github razorpay international payments Razorpay payment gateway integration in CodeIgniter razorpay payment gateway integration in php code Razorpay payment gateway integration with PHP and CodeIgniter Razorpay payment gateway setup in CodeIgniter Library & Frameworks Tips & Tricks UI/UX & Front-end coding birds online html code for google sign in login with google account in PHP login with google account using javascript login with google account using javascript codeigniter login with google account using php login with google account using php source code