How To Install Git on CentOS

Git is a popular version control system that enables developers to manage source code, track changes, and collaborate on software development projects. If you are a CentOS user and want to start using Git, this step-by-step guide will help you install Git on your CentOS server.

Step 1: Update Package Manager

Before installing Git on CentOS, it’s essential to update the package manager to ensure that you are downloading the latest version of Git. To do this, open your terminal and enter the following command:

sudo yum update

Step 2: Install Git

After updating the package manager, it’s time to install Git. Enter the following command to install Git:

sudo yum install git

The installation process will take a few minutes, depending on your internet speed.

Step 3: Verify Git Installation

Once the installation is complete, verify Git’s version to ensure that it was installed correctly. You can do this by entering the following command:

git --version

If Git was installed successfully, the terminal should display the installed Git version.

See also  How to Add the RPMforge Repository on CentOS 5/RHEL 5 Linux Server

For example:

dimitri@geeks:~# git --version
git version 2.17.1

Options:

dimitri@geeks:~# git --help
usage: git [--version] [--help] [-C ] [-c =]
           [--exec-path[=]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=] [--work-tree=] [--namespace=]
            []


These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help ' or 'git help '
to read about a specific subcommand or concept.

Commands Mentioned:

  • yum update – updates the package manager
  • yum install git – installs Git on CentOS
  • git –version – verifies the Git installation and displays the installed version

Conclusion:

In this guide, we have learned how to install Git on CentOS. By following the steps outlined above, you can start using Git to manage source code and collaborate on software development projects.

If you have any questions or suggestions for improvements, please feel free to leave a comment.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *