All Programming Language Programmer Should Learn Important Git Commands

By Kimberly Cook |Email | Feb 8, 2019 | 79173 Views

There are few tools on which developers need to have hands-on other than code editors. Git, a Version control system is one of those tools every programmer need to learn. This tool really helps coders in the work environment while they develop a project in collaboration. Git is the widely used and powerful version control system, that keeps track of files & history and manage projects. It is an open-source platform that can be used for free. It is available for different operating systems. Here you can download and install to Windows and Linux.

Here are some of the git commands that really helps the newbie programmer to get started with Git

1. Git Config
This command is used to set your name and email in the main configuration file. And It is also helpful to check your name and email

git config-global user.name
git config-global user.email

Set up your name and email

git config-global user.name = "Your_name"
git config-global user.email = "your_email_address"

2. Git Init
This command is used to initialize the new and empty repository. And also helps to convert the unversioned and existing project to Git repository, The git init command also known as root command, which is used to run at the beginning of the new or existing project. Because all other git commands are not available to run outside of the initialized repository.

git init

3. Git Remote
This command is used to check and list the remote/source you have, also it adds the new remote/source repository. Here remote means the place where your code is stored, it is either Github or external server.

Check and list the remote repository

git remote

Adding the new remote URL

git remote add <remote_name> <remote_URL>

4. Git Clone
This command targets an existing repository and creates its clone, i.e., a copy of an existing repository. This copied repository has a different location from the existing one, contains it's own history and manages its own files.

Cloning an existing repository

git clone <clone_url>

5. Git Status
This command is helpful to check the status of the working directory. It shows all the changes since the last commit of the working directory.

Apply the command inside the working directory and it lists all the files that have changed

git status

6. Git Add
To the current directory, git add command adds all modified or new or untracked files. And it also adds subdirectories to staging/index area, these directories are included in the next git commit.

Using this command you can add files to the staging area

git add.

7. Git Commit
This command promotes your changes and set up the new commit object. This object doesn't change unless you commit to any changes.

Commit your changes to remote
git commit -m"any_message"

8. Git Branch
This is a simple command that lists out all the branches.

List out branches of the working directory, projects, or staging area

git branch

To list remote branch use the following

git branch -a

9. Git Checkout
This command will help to switch between the different branches.

Create and switch to a new branch:

git checkout <branch>

or

git checkout -b <branch>

10. Git Reset
This command is a complex and versatile tool. It will help you to undo the changes.

git reset <mode> <COMMIT>

I covered a few of the essential commands from git that are helpful for a newbie, If I missed any then go ahead to comment and help others.

Source: HOB