Install and Configure Git on Linux 9

Install and Configure Git on Oracle Linux 9 – BRIGHT DBA
BRIGHT DBA
▲ DevOps for Oracle DBA

Install and Configure Git on Oracle Linux 9

Complete step-by-step guide covering Git setup, GitHub integration, branching strategy, and daily DBA workflow.

Oracle Linux 9 📄 Git 2.47.3 ⚙ 30 Steps 👥 Rajasekhar Amudala
Hostname
git
OS
OL 9
Git
2.47.3
User
git
Remote
GitHub
00

What is Git & GitHub?

Before starting the 30-step guide, let’s understand the fundamentals.
What is Git?
[Git Basics]
# Created by Linus Torvalds in 2005
Git is a free and open-source Version Control System (VCS).

It allows you to:
• Track changes in your files over time
• Go back to any previous version if something breaks
• Collaborate with others without conflicts
• Create branches to test new ideas safely
What is GitHub?
[GitHub Basics]

GitHub is a web-based platform that hosts Git repositories in the cloud.

It is the most popular Git hosting service used by millions of developers and DBAs worldwide.
Git vs GitHub
FeatureGitGitHub
What it isVersion Control ToolHosting Service for Git
Where it runsOn your computer (Local)On the internet (github.com)
PurposeTrack changes in filesStore, share & collaborate
Internet Required?NoYes
Examplesgit commit, git push, git branchPull Requests, Issues, Actions, Wiki
Simple Analogy:

Git = Microsoft Word’s “Track Changes” (Powerful local version control)
GitHub = Google Drive / Dropbox specially built for code with collaboration features
Summary: Use Git to manage versions locally. Use GitHub to store your projects online and collaborate.
01

Install Git on Linux 9

root@git — dnf install
[root@git ~]# dnf install git -y
Last metadata expiration check: 3:39:21 ago on Mon 11 May 2026 02:42:47 PM.
Dependencies resolved.
========================================================================================
 Package                Architecture Version                  Repository           Size
========================================================================================
Installing:
 git                    x86_64       2.47.3-1.el9_6           ol9_appstream        65 k
Installing dependencies:
 git-core               x86_64       2.47.3-1.el9_6           ol9_appstream       4.7 M
 git-core-doc           noarch       2.47.3-1.el9_6           ol9_appstream       4.1 M
 perl-Error             noarch       1:0.17029-7.el9          ol9_appstream        57 k
 perl-Git               noarch       2.47.3-1.el9_6           ol9_appstream        42 k
 perl-TermReadKey       x86_64       2.38-11.el9              ol9_appstream        42 k
 perl-lib               x86_64       0.65-481.1.el9_6         ol9_appstream        13 k

Transaction Summary
========================================================================================
Install  7 Packages

Total download size: 9.0 M
Installed size: 40 M
Downloading Packages:
(1/7): git-core-2.47.3-1.el9_6.x86_64.rpm               6.0 MB/s | 4.7 MB     00:00
(2/7): perl-Error-0.17029-7.el9.noarch.rpm              223 kB/s |  57 kB     00:00
(3/7): perl-Git-2.47.3-1.el9_6.noarch.rpm               172 kB/s |  42 kB     00:00
(4/7): perl-TermReadKey-2.38-11.el9.x86_64.rpm          1.1 MB/s |  42 kB     00:00
(5/7): perl-lib-0.65-481.1.el9_6.x86_64.rpm             483 kB/s |  13 kB     00:00
(6/7): git-core-doc-2.47.3-1.el9_6.noarch.rpm           1.7 MB/s | 4.1 MB     00:02
(7/7): git-2.47.3-1.el9_6.x86_64.rpm                     20 kB/s |  65 kB     00:03
----------------------------------------------------------------------------------------
Total                                                   2.8 MB/s | 9.0 MB     00:03
Oracle Linux 9 Application Stream Packages (x86_64)     4.3 MB/s | 6.2 kB     00:00
Importing GPG key 0x8D8B756F:
 Userid     : "Oracle Linux (release key 1) <secalert_us@oracle.com>"
 Fingerprint: 3E6D 826D 3FBA B389 C2F3 8E34 BC4D 06A0 8D8B 756F
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                1/1
  Installing       : git-core-2.47.3-1.el9_6.x86_64                                 1/7
  Installing       : git-core-doc-2.47.3-1.el9_6.noarch                             2/7
  Installing       : perl-lib-0.65-481.1.el9_6.x86_64                               3/7
  Installing       : perl-TermReadKey-2.38-11.el9.x86_64                            4/7
  Installing       : perl-Error-1:0.17029-7.el9.noarch                              5/7
  Installing       : perl-Git-2.47.3-1.el9_6.noarch                                 6/7
  Installing       : git-2.47.3-1.el9_6.x86_64                                      7/7
  Running scriptlet: git-2.47.3-1.el9_6.x86_64                                      7/7
  Verifying        : git-2.47.3-1.el9_6.x86_64                                      1/7
  Verifying        : git-core-2.47.3-1.el9_6.x86_64                                 2/7
  Verifying        : git-core-doc-2.47.3-1.el9_6.noarch                             3/7
  Verifying        : perl-Error-1:0.17029-7.el9.noarch                              4/7
  Verifying        : perl-Git-2.47.3-1.el9_6.noarch                                 5/7
  Verifying        : perl-TermReadKey-2.38-11.el9.x86_64                            6/7
  Verifying        : perl-lib-0.65-481.1.el9_6.x86_64                               7/7

Installed:
  git-2.47.3-1.el9_6.x86_64                  git-core-2.47.3-1.el9_6.x86_64
  git-core-doc-2.47.3-1.el9_6.noarch         perl-Error-1:0.17029-7.el9.noarch
  perl-Git-2.47.3-1.el9_6.noarch             perl-TermReadKey-2.38-11.el9.x86_64
  perl-lib-0.65-481.1.el9_6.x86_64

Complete!
[root@git ~]#

Verify the installation:

root@git — verify
[root@git ~]# git --version
git version 2.47.3
[root@git ~]#
02

Configure Git Username and Email

Note: This is important because every Git commit stores your identity. Configure before making any commits.
git@git — git config
[git@git ~]$ git config --global user.name "Rajasekhar"
[git@git ~]$ git config --global user.email "br8dba@gmail.com"
[git@git ~]$ git config --list
user.name=Rajasekhar
user.email=br8dba@gmail.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
[git@git ~]$
03

Create Git User and Repository Folder

root@git — useradd
[root@git ~]# groupadd git
[root@git ~]# useradd -g git -m -s /bin/bash git
[root@git ~]# passwd git
Changing password for user git.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@git ~]#

[root@git ~]# su - git
[git@git ~]$ mkdir -p /home/git/repos
[git@git ~]$ cd /home/git/repos
[git@git repos]$
04

Initialize Git Repository

git@git — git init
[git@git repos]$ 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 /home/git/repos/.git/
[git@git repos]$
Info: A hidden .git/ directory is created. This is where Git stores all version history and configuration.
05

Create SQL File

git@git — vi create_table.sql
[git@git repos]$ pwd
/home/git/repos
[git@git repos]$ vi create_table.sql
[git@git repos]$ cat create_table.sql
CREATE TABLE emp (
    name        VARCHAR2(100),
    designation VARCHAR2(100),
    project     VARCHAR2(100),
    company     VARCHAR2(100)
);
[git@git repos]$
06

Check Git Status

git@git — git status
[git@git repos]$ git status
On branch master

No commits yet

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

nothing added to commit but untracked files present (use "git add" to track)
[git@git repos]$

-- Git sees the file but is NOT tracking it yet.
07

Add File to Git

git@git — git add
[git@git repos]$ git add create_table.sql
[git@git repos]$

[git@git repos]$ git status
On branch master

No commits yet

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

[git@git repos]$

-- To add all files at once:
git add .
08

Commit First Version

git@git — git commit
[git@git repos]$ git commit -m "Initial emp table"
[master (root-commit) 03feab3] Initial emp table
 1 file changed, 6 insertions(+)
 create mode 100644 create_table.sql
[git@git repos]$
09

Modify Existing File

git@git — edit SQL
[git@git repos]$ vi create_table.sql
[git@git repos]$ cat create_table.sql
CREATE TABLE emp (
    name        VARCHAR2(50),
    designation VARCHAR2(50),
    project     VARCHAR2(50),
    company     VARCHAR2(50)
);
[git@git repos]$
10

View Changes Using git diff

git@git — git diff
[git@git repos]$ git diff create_table.sql
diff --git a/create_table.sql b/create_table.sql
index ef15ed0..62f7356 100644
--- a/create_table.sql
+++ b/create_table.sql
@@ -1,6 +1,6 @@
 CREATE TABLE emp (
-    name        VARCHAR2(100),
-    designation VARCHAR2(100),
-    project     VARCHAR2(100),
-    company     VARCHAR2(100)
+    name        VARCHAR2(50),
+    designation VARCHAR2(50),
+    project     VARCHAR2(50),
+    company     VARCHAR2(50)
 );
[git@git repos]$

-- Red  (-) = removed lines
-- Green(+) = added lines
11

Commit Second Version

git@git — git commit v2
[git@git repos]$ git add create_table.sql
[git@git repos]$ git commit -m "Changed VARCHAR VALUES"
[master 0f8e7e6] Changed VARCHAR VALUES
 1 file changed, 4 insertions(+), 4 deletions(-)
[git@git repos]$

-- Git now internally stores Version 1 and Version 2.
12

View Commit History

git@git — git log
[git@git repos]$ git log --oneline
0f8e7e6 (HEAD -> master) Changed VARCHAR VALUES
03feab3 Initial emp table
[git@git repos]$
13

Create .gitignore File

The .gitignore file tells Git which files or patterns to ignore and never track — useful for log files, temp files, wallet files, and credential files.

git@git — .gitignore
[git@git repos]$ vi .gitignore
[git@git repos]$ cat .gitignore
# Ignore log files
*.log
*.log.*

# Ignore temp files
*.tmp
*.bak

# Ignore Oracle wallet / credential files
*.ora
wallet/
*.p12

# Ignore OS files
.DS_Store
Thumbs.db

[git@git repos]$ git add .gitignore
[git@git repos]$ git commit -m "Added .gitignore"
[master a1b2c3d] Added .gitignore
 1 file changed, 10 insertions(+)
 create mode 100644 .gitignore
[git@git repos]$

-- Verify ignored files are not tracked:
[git@git repos]$ git status
On branch master
nothing to commit, working tree clean
[git@git repos]$
Tip: Add *.log and wallet/ to your Oracle DBA repos to avoid accidentally committing sensitive files or alert logs.
14

Create GitHub Account

Visit https://github.com and sign up for a free account if you don't already have one.

  • Go to github.com and click Sign up
  • Enter your email, create a password, and choose a username
  • Verify your email address
  • Select the Free plan
15

Create GitHub Repository

Click New Repository on GitHub and fill in:

  • Name: oracle-release
  • Visibility: Public or Private
  • Click Create repository

Do NOT initialise with the following (local project already exists):

  • README file
  • .gitignore template
16

Generate GitHub Personal Access Token

Important: GitHub no longer allows password authentication for Git operations. You must use a Personal Access Token (PAT) instead.

Navigate to: GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)

  • Click Generate new token (classic)
  • Add a note, e.g. oracle-dba-git
  • Select scope: repo
  • Click Generate token
  • Copy the token immediately — it won't be shown again
example token
ghp_KVxvib0FhfTp5NK3xxxBhE8E4h9BY4Uxxx
17

Connect Local Repository to GitHub

git@git — git remote add
[git@git repos]$ git remote add origin https://github.com/ramudala/repo.git
[git@git repos]$

[git@git repos]$ git remote -v
origin  https://github.com/ramudala/repo.git (fetch)
origin  https://github.com/ramudala/repo.git (push)
[git@git repos]$
18

Rename Default Branch to main

git@git — git branch -M
[git@git repos]$ git branch
* master
[git@git repos]$

[git@git repos]$ git branch -M main
[git@git repos]$ git branch
* main
[git@git repos]$
19

Push Code to GitHub

Note: When prompted for Password, enter your Personal Access Token (PAT) — NOT your GitHub account password.
git@git — git push
[git@git repos]$ git push -u origin main
Username for 'https://github.com': ramudala
Password for 'https://ramudala@github.com': [enter PAT token]
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 556 bytes | 185.00 KiB/s, done.
Total 6 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/ramudala/repo.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.
[git@git repos]$
20

Verify Repository in GitHub

Verify: Open your GitHub repository URL in a browser. You should see create_table.sql and .gitignore listed with your commit messages. The branch should show main.
  • Files appear in the repository
  • Commit messages are visible
  • Branch name shows as main
  • Commit history matches your local log
21

Daily Git Workflow

Most Important: This is the cycle you repeat every time you make changes.
Daily workflow — git cycle
-- Step 1: Edit your SQL / script file
vi create_table.sql

-- Step 2: Check what changed
git status
git diff

-- Step 3: Stage all changes
git add .

-- Step 4: Commit with a meaningful message
git commit -m "Added index on emp.name"

-- Step 5: Push to GitHub
git push
22

Pull Latest Changes

If another team member or machine has pushed changes, always pull before starting your work:

git@git — git pull
[git@git repos]$ git pull
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (3/3), 974 bytes | 974.00 KiB/s, done.
From https://github.com/ramudala/repo
   0f8e7e6..2b24839  main       -> origin/main
Updating 0f8e7e6..2b24839
Fast-forward
 create_table_emp1.sql | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 create_table_emp1.sql
[git@git repos]$

[git@git repos]$ ls -ltr
total 8
-rw-r--r--. 1 git git 141 May 11 19:00 create_table.sql
-rw-r--r--. 1 git git  39 May 11 20:42 create_table_emp1.sql
[git@git repos]$
23

Create Branches

Create separate branches for DEV and UAT environments:

git@git — git checkout -b
[git@git ~]$ cd repos/
[git@git repos]$ pwd
/home/git/repos

-- Create dev branch
[git@git repos]$ git checkout -b dev
Switched to a new branch 'dev'
[git@git repos]$

-- Create uat branch
[git@git repos]$ git checkout -b uat
Switched to a new branch 'uat'
[git@git repos]$

[git@git repos]$ git branch
  dev
  main
* uat
[git@git repos]$

-- * uat  →  currently checked out branch

-- Alternative modern syntax (Git 2.23+):
[git@git repos]$ git switch -c dev
fatal: a branch named 'dev' already exists
[git@git repos]$
24

Switch Branches

git@git — switch / checkout
-- Classic syntax
[git@git repos]$ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
[git@git repos]$ git branch
  dev
* main
  uat
[git@git repos]$

-- Modern syntax (Git 2.23+)
[git@git repos]$ git switch dev
Switched to branch 'dev'
[git@git repos]$ git branch
* dev
  main
  uat
[git@git repos]$
25

Merge Branches

git@git — git merge dev → main
-- Step 1: Make changes in dev branch
[git@git repos]$ git branch
* dev
  main
  uat
[git@git repos]$ echo "new code" >> test.sql
[git@git repos]$ git add test.sql
[git@git repos]$ git commit -m "Added new changes"
[dev 412d5c8] Added new changes
 1 file changed, 1 insertion(+)
 create mode 100644 test.sql
[git@git repos]$

-- Step 2: Switch back to main
[git@git repos]$ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.

-- Step 3: Merge dev into main
[git@git repos]$ git merge dev
Updating 2b24839..412d5c8
Fast-forward
 test.sql | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 test.sql
[git@git repos]$

-- DEV changes successfully merged into MAIN.
26

Push Branch to GitHub

git@git — git push origin
-- Push merged main to GitHub
[git@git repos]$ git push origin main
Username for 'https://github.com': ramudala
Password for 'https://ramudala@github.com':
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 279 bytes | 139.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/ramudala/repo.git
   2b24839..412d5c8  main -> main
[git@git repos]$

-- Push dev branch to GitHub (make it visible in GitHub UI)
[git@git repos]$ git push -u origin dev
Username for 'https://github.com': ramudala
Password for 'https://ramudala@github.com':
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote:
remote: Create a pull request for 'dev' on GitHub by visiting:
remote:      https://github.com/ramudala/repo/pull/new/dev
remote:
To https://github.com/ramudala/repo.git
 * [new branch]      dev -> dev
branch 'dev' set up to track 'origin/dev'.
[git@git repos]$
27

Delete Branch

git@git — delete local + remote branch
[git@git repos]$ git branch
* dev
  main
  uat

-- Switch to main first (cannot delete the active branch)
[git@git repos]$ git switch main
M       create_table.sql
Switched to branch 'main'
Your branch is up to date with 'origin/main'.

-- Force delete local branch
[git@git repos]$ git branch -D dev
Deleted branch dev (was 412d5c8).
[git@git repos]$

-- Delete remote branch from GitHub
[git@git repos]$ git push origin --delete dev
Username for 'https://github.com': ramudala
Password for 'https://ramudala@github.com':
To https://github.com/ramudala/repo.git
 - [deleted]         dev
[git@git repos]$

-- Verify local branches
[git@git repos]$ git branch
* main
  uat
[git@git repos]$

-- Verify remote branches
[git@git repos]$ git branch -r
  origin/main
[git@git repos]$
28

Restore Older Version

git@git — git checkout <hash>
-- View commit history for specific file
[git@git repos]$ git log --oneline create_table.sql
0f8e7e6 Changed VARCHAR VALUES
03feab3 Initial emp table
[git@git repos]$

-- Current file has VARCHAR2(50)
[git@git repos]$ cat create_table.sql
CREATE TABLE emp (
    name        VARCHAR2(50),
    designation VARCHAR2(50),
    project     VARCHAR2(50),
    company     VARCHAR2(50)
);
[git@git repos]$

-- Restore to original version (commit 03feab3 = VARCHAR2(100))
[git@git repos]$ git checkout 03feab3 create_table.sql
Updated 1 path from e30c8a7
[git@git repos]$

-- Verify restored file now has VARCHAR2(100)
[git@git repos]$ cat create_table.sql
CREATE TABLE emp (
    name        VARCHAR2(100),
    designation VARCHAR2(100),
    project     VARCHAR2(100),
    company     VARCHAR2(100)
);
[git@git repos]$
Note: The restored file is staged but not committed yet. Run git commit to save the rollback, or git restore --staged <file> to undo the restore.
29

Clone Repository on Another Server

To deploy scripts from GitHub to another server (e.g. Oracle DB server), clone the repository:

oracle@git — git clone
[oracle@git ~]$ id
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)
[oracle@git ~]$

[oracle@git ~]$ git clone https://github.com/ramudala/repo.git
Cloning into 'repo'...
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 12 (delta 2), reused 10 (delta 2), pack-reused 0 (from 0)
Receiving objects: 100% (12/12), done.
Resolving deltas: 100% (2/2), done.
[oracle@git ~]$

[oracle@git ~]$ ls -ltr
total 0
drwxr-xr-x. 3 oracle oinstall 87 May 12 15:00 repo
[oracle@git ~]$

[oracle@git ~]$ cd repo/
[oracle@git repo]$ ls -ltr
total 12
-rw-r--r--. 1 oracle oinstall   9 May 12 15:00 test.sql
-rw-r--r--. 1 oracle oinstall 141 May 12 15:00 create_table.sql
-rw-r--r--. 1 oracle oinstall  39 May 12 15:00 create_table_emp1.sql
[oracle@git repo]$
30

Important Git Commands Cheat Sheet

▼ Setup & Config
git --versionCheck Git version
git config --global user.name "x"Set username
git config --global user.email "x"Set email
git config --listView all config
▼ Repository
git initInitialize new repo
git clone <url>Clone remote repo
git remote add origin <url>Connect to GitHub
git remote -vShow remote URLs
▼ Stage & Commit
git statusShow changed files
git add <file>Stage specific file
git add .Stage all changes
git commit -m "msg"Save snapshot
git diffView unstaged changes
▼ History & Restore
git log --onelineShort commit history
git log --oneline <file>History for one file
git checkout <hash> <file>Restore older version
git restore <file>Discard local changes
▼ Branches
git branchList local branches
git branch -rList remote branches
git checkout -b <name>Create + switch branch
git switch <name>Switch branch (new)
git branch -M mainRename branch
git branch -D <name>Force delete branch
▼ Push, Pull & Merge
git pushPush to remote
git push -u origin mainPush & set upstream
git push origin --delete <br>Delete remote branch
git pullFetch + merge remote
git merge <branch>Merge branch into current