Born out of need, Git – developed by the Linux team – has quickly become the dominant version control system for many programmers. That’s because large developer platforms like GitHub or BitBucket are based on the open-source software. Read our complete Git tutorial for beginners and learn the key basics of Git.Git basics: first steps with the version control system
Git cheat sheet: Everything you need at a glance
No matter whether you’ve just taken a first look at a Git tutorial or already have some experience in using the version control system, with a clear Git cheat sheet, you’ll always have all the Git commands and codes at a glance.
Git Cheat Sheet
Version and installation
To check which version of Git is currently on your computer, use the following command:
If you don’t find a version, you can download Git using the following links:
Git is open source and free of charge.
You need a username and a valid email address to work with Git. Here’s how to configure both:
Specify a name
git config --global user.name "your name"
Enter your email address
git config --global user.email "email@example.com"
Create a repository
Create a new repository or download an existing repository.
Create and name a new local repository
git init sample name
Copy an existing repository and its history with Git clone
git clone "http://samplesite.com"
You can make, track and add changes.
Show the status of the directory
Add a file
git add sample file
Add all files from a repository
Show all new or changed files with Git diff
Show any changes between the staging area and the repository
git diff --staged
Track changes after commit
git diff HEAD
Show differences between index and current stage
git reset sample file
Add currently indexed files permanently to the version history with Git commit
git commit -m "Explanations for the changes"
Group changes into branches and integrate new features.
Create and edit
Create a new branch
git branch sample name
List all branches
git branch --list
Delete a branch
git branch -d
Remove a remote branch
git push origin --delete
Rename a branch
git branch -m
Switch to another branch with Git checkout
git checkout other branch
Create a new branch and switch to it
git checkout -b
Merge and fetch
Merge history of a branch with the current branch
git merge sample name
Register external repository and swap history
git fetch "http://www.samplesite.com"
Fetch all branches
git fetch -all
Register a local repository
git fetch origin
Put current changes in your working directory into stash for later use with Git stash
Save changes with an explanation
git stash save "insert explanation here"
git stash list
Make new changes to a stash
git stash apply
Track changes to the stash
git stash show
Apply and delete stash directly
git stash pop
Discard intermediate stashes
git stash drop
Delete all available stashes
git stash clear
Save to a separate branch
git stash branch sample branch
Integrate external branch with current local branch
git push "http://www.samplesite.com" local sample branch
Transfer data to the remote server
git push origin master
git push -f
Remove remote branch via push
git push origin --delete samplebranch
Pull history from external repository
Pull data from server
git pull origin master
You check the history of a commit with Git log.
Show all commits for a branch
Limit the number of commits (in this example to three)
git log -3
Search commits from a specific author
git log --author= "sample name"
Show commits for a specific time period
git log <since>…<until>
Show commits for a specific file
git log sample file
You have two options to revert changes — Git revert or Git reset. For the latter, you can choose between the options “soft”, “hard” and “mixed”.
Modify existing commit
git commit --amend
Remove file from staging area
git reset HEAD samplefile
git restore --staged samplefile
Discard local changes to a file in the staging area
git checkout --samplefile
git restore samplefile
Whether a static website or a single-page application, with Deploy Now from IONOS, you deploy your project in just three steps. During the process, you’ll benefit from useful features such as automatic framework detection and high scalability.