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
[root@localhost devops1]# git log --oneline
2b10a63 (HEAD -> master) My new file or folder
1750a81 Second edit
1c76abf my initai:
Go to gitlab server
http://gitlab.reposerver.com/users/sign_in
Then click Adminà Users
Then click new user
Then click create user
To change password, click edit
Then sign out from Admin
Login through user
User’s interface
To make Repo,Click Projects-àclick a project
Click blank project
Add IP at hostname :
[root@localhost devops]# vi /etc/hosts
Add your files
cd existing_repo
git remote add origin http://gitlab.reposerver.com/centos/mysecondproject.git
git branch -M main
git push -uf origin main
##This code is using https://
From server
[root@localhost ~]# cd devops1
[root@localhost devops1]# git remote add origin http://gitlab.reposerver.com/centos/mysecondproject.git
[root@localhost devops1]# git branch -M main
[root@localhost devops1]# git branch
* main
[root@localhost devops1]# git push -uf origin main
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
Password for 'http://root@gitlab.reposerver.com':
remote: HTTP Basic: Access denied. If a password was provided for Git authentication, the password was incorrect or you're required to use a token instead of a password. If a token was provided, it was either incorrect, expired, or improperly scoped. See http://192.168.184.130:8079/help/topics/git/troubleshooting_git.md#error-on-git-fetch-http-basic-access-denied
fatal: Authentication failed for 'http://gitlab.reposerver.com/centos/mysecondproject.git/'
[root@localhost devops1]# git push -uf origin main
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 2 threads
Compressing objects: 100% (5/5), done.
Solution change main to dummy
[root@localhost devops1]# git push -uf origin dummy
Click cancel to go ahead
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
Username for 'http://gitlab.reposerver.com': centos
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
Password for 'http://centos@gitlab.reposerver.com':
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 2 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (13/13), 892 bytes | 127.00 KiB/s, done.
Total 13 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for dummy, visit:
remote: http://gitlab.reposerver.com/centos/mysecondproject/-/merge_requests/new?merge_request%5Bsource_branch%5D=dummy
remote:
To http://gitlab.reposerver.com/centos/mysecondproject.git
* [new branch] dummy -> dummy
branch 'dummy' set up to track 'origin/dummy'.
Writing objects: 100% (13/13), 892 bytes | 178.00 KiB/s, done.
Total 13 (delta 0), reused 0 (delta 0), pack-reused 0
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
To http://gitlab.reposerver.com/centos/mysecondproject.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'http://gitlab.reposerver.com/centos/mysecondproject.git'
Solution:
[root@localhost devops1]# git branch -M dummy
[root@localhost devops1]# git push -uf origin dummy
remote: HTTP Basic: Access denied. If a password was provided for Git authentication, the password was incorrect or you're required to use a token instead of a password. If a token was provided, it was either incorrect, expired, or improperly scoped. See http://192.168.184.130:8079/help/topics/git/troubleshooting_git.md#error-on-git-fetch-http-basic-access-denied
fatal: Authentication failed for 'http://gitlab.reposerver.com/centos/mysecondproject.git/'
[root@localhost devops1]# git push -uf origin dummy
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
Username for 'http://gitlab.reposerver.com': centos
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
Password for 'http://centos@gitlab.reposerver.com':
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 2 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (13/13), 892 bytes | 127.00 KiB/s, done.
Total 13 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for dummy, visit:
remote: http://gitlab.reposerver.com/centos/mysecondproject/-/merge_requests/new?merge_request%5Bsource_branch%5D=dummy
remote:
To http://gitlab.reposerver.com/centos/mysecondproject.git
* [new branch] dummy -> dummy
branch 'dummy' set up to track 'origin/dummy'.
[root@localhost devops1]# git push -uf origin dummy
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
Username for 'http://gitlab.reposerver.com': centos
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
Password for 'http://centos@gitlab.reposerver.com':
branch 'dummy' set up to track 'origin/dummy'.
Everything up-to-date
Then go the site click main, choose dummy
Click history to see changes
Click of second edit to see what are the changes
No comments:
Post a Comment