Why git?
One of the biggest advantages of Git is its branching capabilities. Unlike centralized version control systems, Git branches are cheap and easy to merge. This facilitates the feature branch workflow popular with many Git users. Feature branches provide an isolated environment for every change to your codebase.
Git local Repository –
Architecture
In simple way:
Installation:(only steps)
-- Create directory structure
Note: For testing I used AWS EC2 system.
[root@example01 ~]# cd /home/ec2-user
[root@example01 ec2-user]# mkdir myproject1
[root@example01 ec2-user]# cd myproject1/
[root@example01 myproject1]# mkdir local.git
[root@example01 myproject1]# ls -la
total 0
drwxr-xr-x. 3 root root 23 Feb 14 14:23 .
drwx------. 4 ec2-user ec2-user 113 Feb 14 14:22 ..
drwxr-xr-x. 2 root root 6 Feb 14 14:23 local.git
[root@example01 myproject1]# pwd
/home/ec2-user/myproject1
[root@example01 myproject1]#
[root@example01 myproject1]#
-- To Un install
yum remove git
yum clean all
[root@example01 ec2-user]# mkdir myproject1
[root@example01 ec2-user]# cd myproject1/
[root@example01 myproject1]# mkdir local.git
[root@example01 myproject1]# ls -la
total 0
drwxr-xr-x. 3 root root 23 Feb 14 14:23 .
drwx------. 4 ec2-user ec2-user 113 Feb 14 14:22 ..
drwxr-xr-x. 2 root root 6 Feb 14 14:23 local.git
[root@example01 myproject1]# pwd
/home/ec2-user/myproject1
[root@example01 myproject1]#
[root@example01 myproject1]#
-- To Un install
yum remove git
yum clean all
-- Installation
[root@example01 myproject1]# cd local.git/
[root@example01 local.git]# pwd
/home/ec2-user/myproject1/local.git
[root@example01 local.git]# yum install git -y
[root@example01 local.git]# git --version
git version 2.31.1
-- before you initialize git, Add Global Variables
cd local.git
# git config --global user.name "gmohapat"
# git config --global user.email "gouranga.mohapatra@oracle.com"
-- Initialize
# git init
Initialized empty Git repository in /home/ec2-user/myproject1/local.git/.git/
Note: All information ll be stored in .git
-- File movement flow
Workspace --> Staging --> Local Repo
[root@example01 local.git]# git commit -m "release 1"
[master (root-commit) 03fcbb5] release 1
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 customerpage.html
[root@example01 local.git]#
[root@example01 local.git]# git log
commit 03fcbb565377435c2e01cf40f12a014fa0d4188c (HEAD -> master)
Author: gmohapat <gouranga.mohapatra@oracle.com>
Date: Tue Feb 14 14:43:22 2023 +0000
release 1
[root@example01 local.git]#
[root@example01 local.git]# git log --oneline
03fcbb5 (HEAD -> master) release 1
[root@example01 local.git]# git show 03fcbb5
commit 03fcbb565377435c2e01cf40f12a014fa0d4188c (HEAD -> master)
Author: gmohapat <gouranga.mohapatra@oracle.com>
Date: Tue Feb 14 14:43:22 2023 +0000
release 1
diff --git a/customerpage.html b/customerpage.html
new file mode 100644
index 0000000..e69de29
[root@example01 local.git]#
[root@example01 local.git]# git log --oneline
7fd29b9 (HEAD -> master) my second file
03fcbb5 release 1
[root@example01 local.git]# git tag -a "phase-2" -m second_commit 03fcbb5
[root@example01 local.git]# git tag
phase-2
[root@example01 local.git]#
Consolidated Commands:
# git status
# touch customerpage.html -- file created in workspace
# git status
# git add . -- file added to staging area/ Index area
# git status
# git commit -m "release 1" -- file added to local repo with changes
# git log -- all commit messages
# git log --oneline -- all commit messages in short message
# git show 03fcbb5 -- single commit message in detail
# git log 5 -- last 5 commit messages
# git tag -a "phase-2" -m second_commit 03fcbb5 -- add tag to commit point
# git tag -- to see all tags
# git tag <tag-name> -- show complete tag info
# git log --grep "release" -- filter all the commit where mesage is like "release"
# git tag -d <tag-name> -- delete specific tag
# git reset <file-name> -- brought back to workspace ( must be before commit)
# git reset --hard -- Complete reset both workspace & stage area, completely remove all changes
No comments:
Post a Comment