Tutorial Git Basic Commands That Beginners Must Know

What is Git? Git is a version control system and used by developers to develop software together. The primary function of Git is to set the version of the source code of your program by putting a line mark and which code is added or replaced.

In recent years, Git has grown rapidly into one of the most widely used version control systems by reliable developers. In this article, I will share some basic GIT commands that must be known by beginners.

Here are the basic GIT commands that must be known by beginners.

Tutorial Git Basic Commands That Beginners Must Know Min

Git revert –no-commit [commit]

Git revert generates a new commit that cancels the changes made by the current commit and generates a new commit with the generated content. If we want to return the previously mentioned commit and avoid the automatic commit, we can use – no-commit atau steno -n.

Git log –no-merges

This git command is used to display the entire commit history that we do, but skip commit that combines two branches.

Git diff -w

Git diff shows changes between two commit, two working trees and two files on disk. When many people work on the same project, there are often changes. Whether it’s the tab text editor or the space settings. To ignore the difference, we can use -w.

Git diff –stat

Displays how each file has changed over time. We can also add three parameters to it, such as:
– width: to override the default output width
– name-width: to set the filename width
– count: limit the output to the first number of rows.

Git stash branch

This command creates a new branch named branch-name, then applies the changes. If no savings provided, use the most recent ones. This allows us to apply the switch to a safer place.

Git reset –soft HEAD^

Reset head to a specific commit without touching index files and trees that are working. All changes made after the commit are moved to the “staged for commit” stage. After that, we just run git commit to adding it back.

Git commit –amend

With git commit –amend, we can change the previous commit, instead of creating a new one. If we have not pushed changes to the remote branch yet, we can use this command to change the latest commit, add recent changes and even change our commit message.

Git branch -a

This command lists all branches outside and local branches. Outside branches are our projects that are broadcasted on the Internet or the network. We can also use –merged to see which branches are fully merged into the parent branch. In this way, we can track our branches and find out which ones are not used anymore and can be removed.

Git add -p

When we use this command, instead of adding all the changes to the index, it passes through each change and asks what we want to do with it. In this way, it allows us to interactively choose what we want to do.

Git pull –rebase

Git pull –rebase forces git to first pull changes and then rebase commits that are not purged onto the latest version of the remote branch. The –rebase option can be used to ensure a linear history by preventing unnecessary merging.

Thus my article about Tutorial Git Basic Commands That Beginners Must Know.

The following two tabs change content below.
This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Leave a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.