There are few tools on which developers need to have a 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 existing repository. This copied repository has a different location from 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 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.

Share.

About Author

Technology Lover | Cool Tech Writer cum Reviewer | Knowledge Seeker and distributor

You may also like



6 Comments

  1. 1)Git push : pushes the changes to remote branch
    Ex: git push -u origin branch name

    2) Git pull: pulls the latest changes from remote branch to local(dev) branch
    Ex: git pull origin branch_name

  2. Ishwar Deoolkar on

    1. git stash : This command used for stash the current changes of current branch which you are currently working directory. But your changes will be not deleted permanently it will keep in stash folder of GitHub..

    And you want to your changes to back to your working directory then type : –

    “git stash pop or git stash apply”

    2. git log – This command is used to see the lastest commit with name of the author and with commit I’d and commit message.

    3. git log –oneline – This command is used to see the latest commit in one line…

    4. git merge – This command is used to merge the master branch into your slave branch.
    For example :- git mereg

    5. git diff – This command bis used to see the difference between your previous change and current change of the files

    6.

  3. git fetch
    updates your repository. It updates all origin/* branches

    git merge
    It merges branch-name specified into your current working branch

Leave A Reply