DevOps Project: Jenkins CI/CD for Kubernetes Deployments

  DevOps Tech Hub

116 Followers

GIT - Commands


How to Install Git

[root@Git ~]#yum install git -y
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:2.23.3-1.amzn2.0.1 will be installed
--> Processing Dependency: perl-Git = 2.23.3-1.amzn2.0.1 for package: git-2.23.3-1.amzn2.0.1.x86_64
--> Processing Dependency: perl(Git::I18N) for package: git-2.23.3-1.amzn2.0.1.x86_64
--> Processing Dependency: perl(Git) for package: git-2.23.3-1.amzn2.0.1.x86_64
--> Running transaction check
---> Package perl-Git.noarch 0:2.23.3-1.amzn2.0.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Installing:
git x86_64 2.23.3-1.amzn2.0.1 amzn2-core 135 k
Installing for dependencies:
 perl-Git           noarch           2.23.3-1.amzn2.0.1             amzn2-core            47 k

Transaction Summary
===============================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 182 k
Installed size: 440 k
Downloading packages:
(1/2): perl-Git-2.23.3-1.amzn2.0.1.noarch.rpm | 47 kB 00:00:00
(2/2): git-2.23.3-1.amzn2.0.1.x86_64.rpm | 135 kB 00:00:00
-----------------------------------------------------------------------------------------------
Total 1.4 MB/s | 182 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : perl-Git-2.23.3-1.amzn2.0.1.noarch 1/2
Installing : git-2.23.3-1.amzn2.0.1.x86_64 2/2
Verifying : git-2.23.3-1.amzn2.0.1.x86_64 1/2
  Verifying  : perl-Git-2.23.3-1.amzn2.0.1.noarch                                          2/2

Installed:
  git.x86_64 0:2.23.3-1.amzn2.0.1

Dependency Installed:
  perl-Git.noarch 0:2.23.3-1.amzn2.0.1

Complete!
[root@Git ~]#

How to check Git version

[root@Git ~]#git version
git version 2.23.3
[kloudways@Git ~]#

How to initialize Git repository

 [root@Git ~]#mkdir /project
[root@Git ~]#cd /project
[root@Git ~]#git init
Initialized empty Git repository in /project/.git/
[root@Git ~]#

How to configure Git user

[root@Git ~]#git config user.name iwayqdev
[root@Git ~]#git config user.email iwayqtech@gmail.com
[root@Git ~]#

How to add files to Git staging

[root@Git ~]#cd /project
[root@Git ~]#git status
On branch master

No commits yet

Untracked files:
(use "git add <file>..." to include in what will be committed)
        README.md

nothing added to commit but untracked files present (use "git add" to track)
[root@Git ~]#git add .
[root@Git ~]#git status
On branch master

No commits yet

Changes to be committed:
(use "git rm --cached <file>..." to unstage)
        new file:   README.md

[root@Git ~]#

How to commit changes to Git repository

[root@Git ~]#git commit -m "code changed"
[master f1f4dd2] code changed
1 file changed, 1 insertion(+)
[root@Git ~]#git status
On branch master
nothing to commit, working tree clean
[root@Git ~]#



Previous Next