Install and Configure Git on Oracle Linux 9
Complete step-by-step guide covering Git setup, GitHub integration, branching strategy, and daily DBA workflow.
What is Git & GitHub?
[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
[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.
| Feature | Git | GitHub |
|---|---|---|
| What it is | Version Control Tool | Hosting Service for Git |
| Where it runs | On your computer (Local) | On the internet (github.com) |
| Purpose | Track changes in files | Store, share & collaborate |
| Internet Required? | No | Yes |
| Examples | git commit, git push, git branch | Pull Requests, Issues, Actions, Wiki |
• Git = Microsoft Word’s “Track Changes” (Powerful local version control)
• GitHub = Google Drive / Dropbox specially built for code with collaboration features
Install Git on Linux 9
[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 ~]# git --version git version 2.47.3 [root@git ~]#
Configure Git Username and Email
[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 ~]$
Create Git User and Repository Folder
[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]$
Initialize Git Repository
[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]$
.git/ directory is created. This is where Git stores all version history and configuration.Create SQL File
[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]$
Check 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.
Add File to Git
[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 .
Commit First Version
[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]$
Modify Existing File
[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]$
View Changes Using 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
Commit Second Version
[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.
View Commit History
[git@git repos]$ git log --oneline 0f8e7e6 (HEAD -> master) Changed VARCHAR VALUES 03feab3 Initial emp table [git@git repos]$
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 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]$
*.log and wallet/ to your Oracle DBA repos to avoid accidentally committing sensitive files or alert logs.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
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
Generate GitHub Personal Access Token
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
ghp_KVxvib0FhfTp5NK3xxxBhE8E4h9BY4UxxxConnect Local Repository to GitHub
[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]$
Rename Default Branch to main
[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]$
Push Code to GitHub
[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]$
Verify Repository in GitHub
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
Daily Git Workflow
-- 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
Pull Latest Changes
If another team member or machine has pushed changes, always pull before starting your work:
[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]$
Create Branches
Create separate branches for DEV and UAT environments:
[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]$
Switch Branches
-- 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]$
Merge Branches
-- 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.
Push Branch to GitHub
-- 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]$
Delete 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]$
Restore Older Version
-- 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]$
git commit to save the rollback, or git restore --staged <file> to undo the restore.Clone Repository on Another Server
To deploy scripts from GitHub to another server (e.g. Oracle DB server), clone the repository:
[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]$
Important Git Commands Cheat Sheet
| git --version | Check Git version |
| git config --global user.name "x" | Set username |
| git config --global user.email "x" | Set email |
| git config --list | View all config |
| git init | Initialize new repo |
| git clone <url> | Clone remote repo |
| git remote add origin <url> | Connect to GitHub |
| git remote -v | Show remote URLs |
| git status | Show changed files |
| git add <file> | Stage specific file |
| git add . | Stage all changes |
| git commit -m "msg" | Save snapshot |
| git diff | View unstaged changes |
| git log --oneline | Short commit history |
| git log --oneline <file> | History for one file |
| git checkout <hash> <file> | Restore older version |
| git restore <file> | Discard local changes |
| git branch | List local branches |
| git branch -r | List remote branches |
| git checkout -b <name> | Create + switch branch |
| git switch <name> | Switch branch (new) |
| git branch -M main | Rename branch |
| git branch -D <name> | Force delete branch |
| git push | Push to remote |
| git push -u origin main | Push & set upstream |
| git push origin --delete <br> | Delete remote branch |
| git pull | Fetch + merge remote |
| git merge <branch> | Merge branch into current |