Site icon UnixArena

Install and configure Git client on RHEL 7 /CentOS 7?

git on Linux CentOS RedHat

git on Linux CentOS RedHat

Install and configure Git client on RHEL 7 /CentOS 7? Git client is a very useful command-line utility to manage git repository from Linux. Git is the most popular distributed version control and source code management system. This article will walk you through how to install git on CentOS 7/ RHEL 7. It also walks you through how to clone the repository and push the updates from the local filesystem.

Pre-requisites

Install Git on RHEL 7 / CentOS 7

1. Login to CentOS 7 / RHEL 7 and gain root access.

2. Install git tool using yum command.

[root@BIVM ~]# yum install git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base: mirror.vanehost.com
extras: mirror.vanehost.com
updates: mirror.vanehost.com
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-21.el7_7 will be installed
--> Processing Dependency: perl-Git = 1.8.3.1-21.el7_7 for package: git-1.8.3.1-21.el7_7.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.3.1-21.el7_7.x86_64
--> Running transaction check
---> Package perl-Git.noarch 0:1.8.3.1-21.el7_7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================
Package Arch Version Repository Size
Installing:
git x86_64 1.8.3.1-21.el7_7 updates 4.4 M
Installing for dependencies:
perl-Git noarch 1.8.3.1-21.el7_7 updates 55 k
Transaction Summary
Install 1 Package (+1 Dependent package)
Total download size: 4.4 M
Installed size: 22 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): perl-Git-1.8.3.1-21.el7_7.noarch.rpm | 55 kB 00:00:02
(2/2): git-1.8.3.1-21.el7_7.x86_64.rpm | 4.4 MB 00:00:18
Total 241 kB/s | 4.4 MB 00:00:18
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : perl-Git-1.8.3.1-21.el7_7.noarch 1/2
Installing : git-1.8.3.1-21.el7_7.x86_64 2/2
Verifying : git-1.8.3.1-21.el7_7.x86_64 1/2
Verifying : perl-Git-1.8.3.1-21.el7_7.noarch 2/2
Installed:
git.x86_64 0:1.8.3.1-21.el7_7

Dependency Installed:
perl-Git.noarch 0:1.8.3.1-21.el7_7
Complete!
[root@BIVM ~]#

3. Check the git version

[root@BIVM ~]# git --version
git version 1.8.3.1
[root@BIVM ~]#

4. Codes can be quickly pushed to github repository using git command line.

Clone the repository using git

1. Use git command line utility to clone the repository

[root@BIVM tmp]# git clone https://github.com/UnixArena/vstackl-test.git
Cloning into 'vstackl-test'…
Username for 'https://github.com': li*****.r*****@gmail.com
Password for 'https://li*******.r******@gmail.com@github.com':
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
[root@BIVM tmp]#

2. Navigate to the git repository local directory and make the changes for testing.

[root@BIVM tmp]# cd vstackl-test/
[root@BIVM vstackl-test]# ls -lrt
total 4
-rw-r--r--. 1 root root 10 Apr 5 08:57 README.md
[root@BIVM vstackl-test]#

3. Edit README.md for testing. Update some text using vi editor.

[root@BIVM vstackl-test]# cat README.md
vstackl
Updated from git command line tool.
[root@BIVM vstackl-test]#

4. Commit the changes on local repository.

[root@BIVM vstackl-test]# git commit -a
[master 9fd6b05] Updated README
1 file changed, 1 insertion(+)
[root@BIVM vstackl-test]#

5. Push the changes to the github repository.

[root@BIVM vstackl-test]# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Username for 'https://github.com': l*******.******y@gmail.com
Password for 'https://l*****.****y@gmail.com@github.com':
Counting objects: 5, done.
Writing objects: 100% (3/3), 309 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/UnixArena/vstackl-test.git
21b6610..9fd6b05 master -> master
[root@BIVM vstackl-test]#

6. Verify the changes on GitHub web UI.

Git Repo – vstackl code changes
Exit mobile version