career git resources tutorial Web Development

Git Cheat Sheet

Person coding with a version control graph in the background
by Marko Denic |

Navigate essential Git commands with this comprehensive cheat sheet, designed to help you handle version control efficiently and confidently.

Initialize a new git repository:

           
git init           
    

Set configuration values for your username and email:

           
git config --global user.name <your-name>
git config --global user.email <your-email>           
    

Clone a repository:

           
git clone <repository-url>           
    

Add a file to the staging area:

           
git add <file>           
    

Add all files changes to the staging area:

           
git add .           
    

Check the unstaged changes:

           
git diff           
    

Commit the staged changes:

           
git commit -m “Message”           
    

Reset staging area to the last commit:

           
git reset           
    

Check the state of the working directory and the staging area:

           
git status           
    

Remove a file from the index and working directory:

           
git rm <file>           
    

List the commit history:

           
git log           
    

Check the metadata and content changes of the commit:

           
git show <commit-hash>           
    

Lists all local branches:

           
git branch           
    

Create a new branch:

           
git branch <branch-name>           
    

Rename the current branch:

           
git branch -m <new-branch-name>           
    

Delete a branch:

           
git branch -d <branch-name>           
    

Switch to another branch:

           
git checkout <branch-name>           
    

Merge specified branch into the current branch:

           
git merge <branch-name>           
    

Create a new connection to a remote repository:

           
git remote add <name> <repository-url>           
    

Push the committed changes to a remote repository:

           
git push <remote> <branch>           
    

Download the content from a remote repository:

           
git pull <remote>           
    

Cleanup unnecessary files and optimize the local repository:

           
git gc           
    

Temporarily remove uncommitted changes and save them for later use:

           
git stash           
    

Reapply previously stashed changes

           
git stash apply           
    
Did you like this article? Share it with your friends:

Related articles

Black desk with a laptop, cup and some writing material

Best Websites To Get HTML/CSS Templates

This roundup will save you hours of wasted search time and license headaches.

Read More
Client Manager Homepage screenshot

ClientManager Review: Onboarding and Client Management In One Place

I signed up to ClientManager. Here’s my review of this tool for freelancers and agencies. What I like and don’t like.

Read More
Web Performance

Web Performance

This article will be some kind of archive for web performance tips.

Read More