The Git version control system can be optimized best with the ap­pro­pri­ate Git commands. We’ll show you the most important commands. Git commands are executed from the terminal.

$1 Domain Names – Register yours today!
  • Simple reg­is­tra­tion
  • Premium TLDs at great prices
  • 24/7 personal con­sul­tant included
  • Free privacy pro­tec­tion for eligible domains

How do I configure a name and email with Git commands?

A username and valid email address are required to work on a project. Use the following Git commands to configure these.

Configure your username:

git config --global user.name "example name"

Check your username:

git config --global user.name

Enter your email address:

git config --global user.email "exampleaddress@example.com"

This is how you access your email:

git config --global user.email

This command will show all your entries in the overview:

git config --global --list

How do I check the overview and changes?

There are several important Git commands that make it easier for you to work on and in your repos­i­to­ry. This command will give an overview of the repos­i­to­ry:

git close gitexample@example.com:Repository.get

This gives you an overview of the local status and the changes that have not been adjusted yet:

git status

The changes are high­light­ed in red.

Use Git Diff to check for dif­fer­ences between the pending commit and the last current version:

git diff HEAD

What are the Git Commands for repos­i­to­ries?

The following Git commands allow you to save changes to the local repos­i­to­ry yourself.

Use this command to add all new, changed or deleted files:

git add

However, if you only want to apply certain changes to your commit, put them in square brackets after the command:

git add [ file_1 file_2 file_3 | file-pattern ]

Finalize a Git commit using this command:

git commit

Use this command to send ex­pla­na­tions about the current step:

git commit -m "Here’s your message"

Show the current commits in your local repos­i­to­ry with Git Log:

git log

What are the Git commands for branches

The following Git commands are required to work with a branch.

List all branches:

git branch

In­for­ma­tion about the different branches:

git fetch

List of all branches in the local repos­i­to­ry:

git branch -a

Create a new branch:

git branch new-branch-name

Switch to a specific branch with Git Checkout:

git checkout name-of-another-branch

Create a new branch and switch to it:

git checkout -b new-branch

Move the new branch from the local repos­i­to­ry to the commit repos­i­to­ry:

git push -i remote-name new-branch

Delete a branch in the local repos­i­to­ry as long as it contains accepted changes only:

git branch -d branch-name

Add changes from a branch to the current branch:

git merge other-branch-name

Retrieve changes from a remote repos­i­to­ry with Git Pull:

git pull other-branch

What are the Git commands for tags?

These Git Commands will make your job easier if you use tags.

List all tags:

git tag

Retrieve all tags from the commit repos­i­to­ry for your local repos­i­to­ry:

git fetch --tags

Display a specific day:

git show tag-name

Push a specific tag to the commit repos­i­to­ry with Git Push:

git push remote-name tag-example

Push all tags to the commit repos­i­to­ry:

git push remote-name --tags

Delete tag in a local repos­i­to­ry:

git tag -d tag-example

Using Git optimally

These Git commands will enable you to work quickly and ef­fec­tive­ly in the version control system. You’ll also find a Git tutorial for getting started as well as a Git cheat sheet with a PDF download in our Digital Guide. If you are looking for an al­ter­na­tive to Linus Torvalds system, our com­par­i­son of Git vs. SVN might be of interest to you.

Tip

Bring your project online in just three steps with Deploy Now from IONOS. Static websites and single page apps can be made available to your customers even faster than before.

Go to Main Menu