Git control version
[root@localhost ~]# git version
git version 2.43.7
[root@localhost ~]# mkdir git
[root@localhost ~]# ls
git
[root@localhost ~]# rm -rvf git -à To remove git directory
removed directory 'git'
[root@localhost ~]# ls
[root@localhost ~]# mkdir devops1
[root@localhost ~]# cd devops1
[root@localhost devops1]# ls
index.html storage test1.html test2.html
[root@localhost devops1]# vi index.php
[root@localhost devops1]# ls
index.html index.php storage test1.html test2.html
[root@localhost devops1]# git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /root/devops1/.git/
[root@localhost devops1]# ls
index.php
[root@localhost devops1]# git init
Reinitialized existing Git repository in /root/devops1/.git/
[root@localhost devops1]# ls -al
total 8
drwxr-xr-x 3 root root 35 Jun 7 08:06 .
dr-xr-x---. 17 root root 4096 Jun 7 08:04 ..
drwxr-xr-x 7 root root 119 Jun 7 08:06 .git -àchanges, history are there in .git
-rw-r--r-- 1 root root 13 Jun 7 08:05 index.php
You have new mail in /var/spool/mail/root
[root@localhost devops1]# git init
Reinitialized existing Git repository in /root/devops1/.git/
[root@localhost devops1]# git add index.php
[root@localhost devops1]# git commit -m "my initai:"
[master (root-commit) 1c76abf] my initia:
Committer: root <root@localhost.localdomain>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:
[root@localhost devops1]# git log
commit 1c76abf4b7aa4dbb187240853904ff23ed5ae527 (HEAD -> master)
Author: root <root@localhost.localdomain>
Date: Sun Jun 7 08:15:31 2026 +0545
my initia:
[root@localhost devops1]# git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.php
no changes added to commit (use "git add" and/or "git commit -a")
git config --global --edit
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
1 file changed, 1 insertion(+)
create mode 100644 index.php
[root@localhost devops1]# git config --global user.email "dummy@gmail.com
> "
[root@localhost devops1]# git config --global user.name "dummy name
"
[root@localhost devops1]# git commit -m "my initia:"
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.php
no changes added to commit (use "git add" and/or "git commit -a")
[root@localhost devops1]# git log
commit 1c76abf4b7aa4dbb187240853904ff23ed5ae527 (HEAD -> master)
Author: root <root@localhost.localdomain>
Date: Sun Jun 7 08:15:31 2026 +0545
my initai:
[root@localhost devops1]# git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.php
no changes added to commit (use "git add" and/or "git commit -a")
[root@localhost devops1]# git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.php
no changes added to commit (use "git add" and/or "git commit -a")
[root@localhost devops1]# vi index.php ---To add somethings
[root@localhost devops1]# git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.php -à Modified
[root@localhost devops1]# git add index.php
[root@localhost devops1]# git commit -m "Second edit"
[master 1750a81] Second edit
1 file changed, 2 insertions(+), 1 deletion(-)
[root@localhost devops1]# git log
commit 1750a8180a8f4cb0061e06cacf6e33a97f47659c (HEAD -> master)
Author: dummy name <dummy@gmail.com>
Date: Sun Jun 7 08:38:48 2026 +0545
Second edit
commit 1c76abf4b7aa4dbb187240853904ff23ed5ae527
Author: root <root@localhost.localdomain>
Date: Sun Jun 7 08:15:31 2026 +0545
my initai:
[root@localhost devops1]# git log --oneline
1750a81 (HEAD -> master) Second edit
1c76abf my initai:
[root@localhost devops1]# git diff 1c76abf
diff --git a/index.php b/index.php
index 9409bd5..3c27a89 100644
--- a/index.php
+++ b/index.php
@@ -1 +1,2 @@
- hello world à changes line
+ hello Son à add line
+Today is sunday
[root@localhost devops1]# vi index.php -à change o to 0(zero)
[root@localhost devops1]# git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.php
[root@localhost devops1]# git diff
diff --git a/index.php b/index.php
index 3c27a89..849002d 100644
--- a/index.php
+++ b/index.php
@@ -1,2 +1,2 @@
- hello Son àchange o
+ hello S0n à change 0
Today is sunday
[root@localhost devops1]# git log --oneline
1750a81 (HEAD -> master) Second edit
1c76abf my initai:
[root@localhost devops1]# git show 1750a81
commit 1750a8180a8f4cb0061e06cacf6e33a97f47659c (HEAD -> master)
Author: dummy name <dummy@gmail.com>
Date: Sun Jun 7 08:38:48 2026 +0545
Second edit
diff --git a/index.php b/index.php
index 9409bd5..3c27a89 100644
--- a/index.php
+++ b/index.php
@@ -1 +1,2 @@
- hello world
+ hello Son
+Today is sunday
Example:https://github.com/SeptiawanAjiP/dewakoding-project-management ...168 commit
[root@localhost devops1]# echo test1>test1.html
[root@localhost devops1]# echo test2>test2.html
[root@localhost devops1]# ls
index.php test1.html test2.html
[root@localhost devops1]# git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
test1.html
test2.html
To track file
[root@localhost devops1]# mkdir storage
[root@localhost devops1]# ls
index.php storage test1.html test2.html
[root@localhost devops1]# echo dummy1 > storage/file1.html
[root@localhost devops1]# echo dummy2 > storage/file2.html
[root@localhost devops1]# git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
storage/
test1.html
test2.html
To tracked each file/folder
[root@localhost devops1]# pwd
/root/devops1
[root@localhost devops1]# ls
index.php storage test1.html test2.html
[root@localhost devops1]# git add /root/devops1/test1.html
[root@localhost devops1]# git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: test1.html
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
storage/
test2.html
To tracked all files/folder at once
[root@localhost devops1]# git add .
[root@localhost devops1]# git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: index.php
new file: storage/file1.html
new file: storage/file2.html
new file: test1.html
new file: test2.html
To restore track
[root@localhost devops1]# git restore test
test1.html test2.html
[root@localhost devops1]# git restore --staged test2.html
[root@localhost devops1]# git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: index.php
new file: storage/file1.html
new file: storage/file2.html
new file: test1.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
test2.html
No comments:
Post a Comment