Mar 6, 2023

Git setup and useful commands

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

-- 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

1 comment:

  1. I am a happy person today having to have recovered a large amount of money worth 10,000, which I had lost in the hands of Bitcoin fraudulent, It has been an unfortunate year for me trying to recover my money back for the last 2months but luckily a friend of mine who also went through the same scamming issue referred me to this recovery agent called Boleyn Magic Hackers It took 3days for them to recovery the full amount at first I was hesitant and scared to believe them since I have also lost some money trying to recover my money back, But my friend assured me that they are very reliably and I decided to try it a try I have never been happy in my life until today, I would advise anyone out here trying to recover your money back you all should trust Boleyn Magic Hackers If you are a victim of bitcoin scam and believe in recovering all your lost funds, Their insights, and dedication showed me a path to success I never knew existed. This is the Email address you can use to reach out to them: Email:support@boleynonline.com. I am aware that sometimes Bitcoin cannot be recovered. However, I think it's critical to provide this choice to those who have misplaced their Bitcoin. We appreciate you offering this helpful service, Boleyn Magic Hackers (BMH). My life was spared by Boleyn Experts, which is why I am sharing this Bitcoin recovery success story in their honor. I am also appreciative of how popular Bitcoin recovery is becoming. This implies that more users will be able to use Boleyn Magic Hackers' online recovery through email:support@boleynonline.com to recover their lost Bitcoin because more people will be aware of the scam.

    ReplyDelete

Translate >>