[Linux] 08 Linux Shell Programming & Git
- Period 1: What is Shell \& First Script
- Shell Basics π
- Types of Shell at One Glance π
- Shebang (
#!) π - Two Ways of Running a Script βΆοΈ
- Period 2: Variables \& Input
- Variables π¦
- Environment Variable \&
exportπ - Special Variables β‘
readCommand β¨οΈ- Period 3: Control Flow, Functions \& Automation
- Conditional Statements:
if / elif / else / fiπ testOperator π§ͺ- Loop Statements π
- Function π οΈ
- Debugging π
- Period 4: Working / Staging / Repository
- Why Version Management is Necessary π
- 3 Areas of Git: Working / Staging / Repository ποΈ
git add\&git commitπgit statusgit diffgit logπ- Period 5: Branch / Merge / Conflict
- Branch πΏ
- Branch Commands:
branchswitchcheckoutπΏ - 2 Ways of Merge: Fast-Forward vs 3-Way Merge π
- Why Conflicts Occur? β οΈ
- Period 6: Remote Repository \& Collaboration
- Remote Storage: Local β Server Relationship π
git push\&git pullπgit cloneπ₯clonevsinitβοΈgit fetchvsgit pullπgit fetchgit pull- Main Difference βοΈ
- When to Use Each π οΈ
- Learning Objectives: Git Advanced \& AI π―
git stash: Temporary Storage Management ποΈβ³- Git Reset vs. Revert: Undoing Changes πβ οΈ
- File Tracking Exclusion: .gitignore Rules π‘οΈπ«
- Git Commit Message Conventions πβ¨
Period 1: What is Shell & First Script
π― Learning Objectives
- Understand what the Linux shell is
- Learn the relationship between:
- π€ User
- π» Shell
- βοΈ Kernel
- Explore common shells:
sh,bash,zsh,dash
- Understand what a shell script is
- Create and run a simple
.shscript - Learn basic command automation with shell scripting
Shell Basics π
- A shell is a command interpreter in Linux
- It connects the π€ user and βοΈ Linux kernel
- Users enter commands through the shell
- The shell interprets commands and passes them to the kernel
Main Structure
π€ User β π Shell β βοΈ Kernel
Common Shell Types
sh: original UNIX shellbash: most common Linux shellzsh: advanced/customizable shelldash: lightweight and fast shell
Types of Shell at One Glance π
| Shell | νΉμ§ |
|---|---|
sh | κΈ°λ³Έ UNIX shell |
bash | κ°μ₯ λ리 μ¬μ©λλ Linux shell |
zsh | κ°λ ₯ν κΈ°λ₯ + λμ μ¬μ©μ μ€μ κ°λ₯ |
dash | κ°λ³κ³ λΉ λ₯Έ shell |
Key Point π‘
Different shells provide different:
- κΈ°λ₯ (features)
- μ±λ₯ (performance)
- μ¬μ©μ κ²½ν (user experience)
Shebang (#!) π
A shebang specifies which shell or interpreter should execute the script. It is written on the first line of a script file and helps ensure the script runs in the correct environment.
Example
#!/bin/bash
Purpose π―
- Ensures the script runs with the correct shell
- Improves script consistency across environments
Common Interpreters
/bin/bash/bin/sh/usr/bin/python
Two Ways of Running a Script βΆοΈ
Shell scripts can be executed in two main ways.
1. Run with Shell Command
This method explicitly runs the script using a shell interpreter.
bash script.sh
- No execute permission required
- Useful for testing scripts quickly
2. Run as Executable File
This method runs the script directly as a program.
./script.sh
Before execution, permission must be added:
chmod +x script.sh
- Requires execute permission
- Commonly used for actual script execution
Period 2: Variables & Input
π― Learning Objectives
- Understand how to declare and use variables in shell scripts
- Learn the difference between:
- local variables
- environment variables
- Receive user input using the
readcommand - Display variable values with
echo - Build simple interactive shell scripts
Variables π¦
Variables are used to store data in shell scripts. Values can be saved and reused later in the script.
Variable Declaration
name="Alice"
Using Variables
echo $name
Key Points π‘
- No spaces around
= - Access variables using
$ - Variables help make scripts flexible and reusable
Environment Variable & export π
Environment variables are variables shared across the system or child processes. They are commonly used to store system settings and configuration values.
Exporting a Variable
export NAME="Alice"
Checking Environment Variables
echo $NAME
Key Points π‘
exportmakes a variable available to child shells/processes- Environment variables can be accessed globally within the session
- Common examples:
PATHHOMEUSER
Special Variables β‘
Special variables store important information automatically provided by the shell.
Common Special Variables
$0: script name$1,$2β¦ : command-line arguments$#: number of arguments$@: all arguments$$: current process ID$?: exit status of previous command
Example
echo $1
This prints the first command-line argument passed to the script.
read Command β¨οΈ
The read command is used to receive input from the user during script execution.
Basic Example
read name
echo $name
With Arguments
read -p "Enter your name: " name
Common Arguments
p: display a prompt messages: hide user input (e.g. password)t: set time limit for input
Key Points π‘
- Stores user input into variables
- Useful for interactive scripts
- Often combined with
echo
Period 3: Control Flow, Functions & Automation
π― Learning Objectives
- Understand conditional statements using
if - Learn repetition with loops:
forwhile
- Create reusable functions in shell scripts
- Automate repetitive tasks using scripts
- Combine variables, input, and control flow to build practical shell programs
Conditional Statements: if / elif / else / fi π
Conditional statements allow scripts to make decisions based on conditions.
Basic Structure
if [ condition ]; then
command
elif [ condition ]; then
command
else
command
fi
Example
if [ $num -gt 0 ]; then
echo "positive"
else
echo "not positive"
fi
Key Points π‘
ifchecks a conditionelifadds additional conditionselseruns when all conditions are falsefiends the conditional block
test Operator π§ͺ
The test operator is used to evaluate conditions in shell scripts. It is commonly written inside [ ].
if [ condition ]; then
command
fi
| Number Comparison | Meaning |
|---|---|
-eq | equal to |
-ne | not equal to |
-gt | greater than |
-lt | less than |
-ge | greater than or equal to |
-le | less than or equal to |
| String Comparison | Meaning |
|---|---|
= | strings are equal |
!= | strings are different |
-z | string is empty |
-n | string is not empty |
| File Validation | Meaning |
|---|---|
-f | file exists and is a regular file |
-d | directory exists |
-e | file or directory exists |
-r | file is readable |
-w | file is writable |
-x | file is executable |
Loop Statements π
Loop statements repeatedly execute commands while a condition is satisfied.
for Loop
The for loop repeats commands for a list of values.
for i in 1 2 3
do
echo $i
done
while Loop
The while loop repeats commands while a condition is true.
count=1
while [ $count -le 3 ]
do
echo $count
count=$((count+1))
done
Key Points π‘
foris useful when the number of repetitions is knownwhileis useful when repetition depends on a conditiondoneends the loop block
Function π οΈ
Functions are reusable blocks of commands in shell scripts. They help organize code and avoid repetition.
Defining a Function
hello() {
echo "Hello"
}
Calling a Function
hello
Example
greet() {
echo "Hello, $1"
}
function add() {
echo $(($1 + $2))
}
greet Lian # Hello, Lian
add 3 5 # 8
result=$(add 10 20)
echo "SUM: $result" # sum: 30
Key Points π‘
- Functions improve code reusability
- A function runs only when it is called
- Useful for automation and modular scripting
Debugging π
Debugging helps identify and fix errors in shell scripts. Shell options can display execution details and stop scripts when problems occur.
Common Debugging Options
| Option | Meaning |
|---|---|
-x | display commands and arguments during execution |
-e | exit immediately if a command fails |
-u | treat undefined variables as errors |
Example
bash -x script.sh
# run script in debug mode and print each command
bash -e script.sh
# stop script immediately when an error occurs
bash -u script.sh
# generate an error if an undefined variable is used
Key Points π‘
- Useful for finding script errors quickly
- Helps trace command execution step-by-step
- Improves script reliability and troubleshooting
Period 4: Working / Staging / Repository
π― Learning Objectives
- Understand the basic structure of Git
- Learn the difference between:
- Working Directory
- Staging Area
- Repository
- Track file changes using Git
- Move files through the Git workflow:
- edit β stage β commit
- Understand how version control manages project history
Why Version Management is Necessary π
Version management helps track and manage changes in files and projects over time. It is especially important when multiple people work on the same project.
Why It Is Needed
- Prevents file overwrite problems
- Makes collaboration easier
- Allows recovery of previous versions
- Tracks who changed what and when
- Helps manage project history systematically
Without Version Control β
Multiple copied files:
final_v1 final_v2 final_real_final- Difficult to track changes
- High risk of mistakes
With Git β
- Organized change history
- Easy rollback and recovery
- Efficient team collaboration
3 Areas of Git: Working / Staging / Repository ποΈ
Git manages files through three main areas during version control.
1. Working Directory
The area where files are created and edited.
- Actual project files exist here
- Changes are not yet tracked by commit
2. Staging Area
A temporary area that prepares files before committing.
git add file.txt
# move file to staging area
- Selects which changes will be included in the commit
- Also called the βindexβ
3. Repository
The area where committed versions are permanently stored.
git commit -m "update file"
# save staged changes into repository
- Stores project history
- Allows version tracking and recovery
Git Workflow π
Working Directory β Staging Area β Repository
git add & git commit π
git add and git commit are core Git commands used to save project changes.
git add
The git add command moves changes from the Working Directory to the Staging Area.
git add file.txt
# stage a specific file
git add .
# stage all changed files
git commit
The git commit command saves staged changes into the Repository.
git commit -m "update file"
# create a commit with a message
Key Points π‘
git addprepares files for commitgit commitpermanently records changes- Commit messages should clearly describe the change
Workflow π
Working Directory β git add β Staging Area β git commit β Repository
git status git diff git log π
These commands help check file changes and Git history.
git status
Shows the current state of files in the repository.
git status
# check modified, staged, or untracked files
git diff
Shows detailed differences between file versions.
git diff
# compare current changes with previous state
git log
Displays commit history.
git log
# show commit records and history
Key Points π‘
statuschecks current repository statediffshows exact file changeslogtracks commit history and previous work
Period 5: Branch / Merge / Conflict
π― Learning Objectives
- Understand the purpose of Git branches
- Create and switch between branches
- Merge changes from different branches
- Understand what merge conflicts are
- Learn basic conflict resolution during collaboration
- Use branching workflows for safer development and teamwork
Branch πΏ
A branch is an independent line of development in Git. It allows developers to work on new features or changes without affecting the main project.
Create a Branch
git branch feature
# create a new branch named "feature"
Switch Branch
git checkout feature
# move to the "feature" branch
Create and Switch at Once
git checkout -b feature
# create and immediately switch to branch
Key Points π‘
- Branches allow parallel development
- Changes in one branch do not affect others immediately
- Commonly used for:
- new features
- bug fixes
- experiments
Branch Commands: branch switch checkout πΏ
These commands are used to create, view, and move between Git branches.
git branch
Creates or lists branches.
git branch
# show all branches
git branch feature
# create a new branch named "feature"
git branch -d feature
# delete branch named "feature"
# -D is force delete
git branch -m feature-image
# Rename current branch to "feature-image"
git switch
Moves to another branch.
git switch feature
# switch to the "feature" branch
git switch -c feature
# create a new branch named "feature" and switch to it.
# *** This is mostly used. ***
git checkout
Older command used for switching branches and restoring files.
git checkout feature
# switch to the "feature" branch
Key Points π‘
branchmanages branchesswitchis mainly for changing branchescheckoutis an older multifunction commandswitchis generally clearer and safer for branch switching
2 Ways of Merge: Fast-Forward vs 3-Way Merge π
Git provides different merge methods depending on branch history.
Fast-Forward Merge
A fast-forward merge occurs when the target branch has no new commits, so Git simply moves the branch pointer forward.
git merge feature
# branch pointer moves forward directly
νΉμ§
- Simple and clean history
- No extra merge commit created
- Happens when histories do not diverge
3-Way Merge
A 3-way merge occurs when both branches have separate commits. Git creates a new merge commit to combine histories.
git merge feature
# create merge commit when histories diverged
νΉμ§
- Preserves branch history
- Creates an additional merge commit
- Used when branches changed independently
Comparison π
| Merge Type | νΉμ§ |
|---|---|
| Fast-Forward | simple linear history |
| 3-Way Merge | combines separate branch histories |
Why Conflicts Occur? β οΈ
A merge conflict occurs when Git cannot automatically combine changes from different branches.
Common Causes
- Two branches modify the same line of a file
- One branch deletes a file while another edits it
- Different developers make incompatible changes
Example Situation
Branch A β edits line 10
Branch B β also edits line 10
Git cannot determine which change should be kept automatically.
Conflict Example
<<<<<<< HEAD
Hello World
=======
Hello Git
>>>>>>> feature
Key Points π‘
- Conflicts usually happen during
merge - Developers must manually choose or combine changes
After resolving conflicts:
git add . git commit
Period 6: Remote Repository & Collaboration
π― Learning Objectives
- Understand the role of remote repositories
- Connect local repositories with remote repositories
- Learn basic collaboration workflow using Git
- Upload and download changes using:
pushpullclone
- Collaborate with multiple developers through shared repositories
- Understand basic GitHub-based teamwork
Remote Storage: Local β Server Relationship π
A remote repository is a shared repository stored on a server such as GitHub. Developers synchronize local work with the remote repository for collaboration.
Relationship Structure
Local Repository β Remote Repository(Server)
Main Workflow
Upload local changes:
git push # send local commits to remote repositoryDownload remote changes:
git pull # fetch and merge changes from remote repositoryCopy remote repository:
git clone URL # create local copy of remote repository
Key Points π‘
- Local repository stores personal work
- Remote repository enables collaboration and backup
- Team members share code through the remote server
git push & git pull π
git push and git pull are used to synchronize local and remote repositories.
git push
Uploads local commits to the remote repository.
git push -u origin main
# upload commits and set upstream branch
u Option
umeans-set-upstream- Connects the local branch with the remote branch
After setting upstream, shorter commands can be used:
git push git pull
git pull
Downloads changes from the remote repository and merges them into the local repository.
git pull origin main
# fetch + merge remote changes
How pull Works βοΈ
git pull is a combination of:
git fetch
# download remote changes
git merge origin/master
# merge downloaded changes into current branch
Key Points π‘
pushuploads local work to the serverpullupdates the local repositorypull = fetch + merge- Used for synchronization and collaboration
git clone π₯
git clone creates a local copy of a remote repository. It automatically downloads the repository, including commit history and branches.
Basic Command
git clone <repository_url>
# copy remote repository to local machine
Example
git clone <https://github.com/user/project.git>
# clone GitHub repository
Commonly Used Options
git clone -b dev <repository_url>
# clone and switch to specific branch
git clone --depth=1 <repository_url>
# shallow clone with limited commit history
| Option | Meaning |
|---|---|
-b <branch> | clone specific branch |
--depth 1 | download only recent commit history |
clone vs init βοΈ
git clone
Used when copying an existing remote repository.
git clone <repository_url>
- Downloads existing project
- Includes commit history and branches
- Automatically connects remote repository
git init
Used when creating a new local Git repository.
git init
- Starts a new empty repository
- No remote connection by default
- Used for new projects
Comparison π
| Command | Purpose |
|---|---|
git clone | copy existing remote repository |
git init | create new local repository |
git fetch vs git pull π
Both commands retrieve changes from a remote repository, but they behave differently.
git fetch
git fetch downloads changes from the remote repository without modifying the current working branch.
git fetch origin
# download remote updates only
What It Does
- Downloads new commits and branch information
- Updates remote tracking branches
- Does NOT change local files automatically
- Allows developers to review changes safely before merging
Workflow
Remote Repository β Local Remote Tracking Branch
νΉμ§ π‘
- Safe operation
- No automatic merge
- Useful before manual review
git pull
git pull downloads remote changes and immediately merges them into the current branch.
git pull origin main
# fetch + merge remote changes
What It Does
- Fetch remote changes
- Automatically merge into current branch
Internal Process
git fetch
git merge
Workflow
Remote Repository β Fetch β Merge β Current Branch
νΉμ§ π‘
- Faster and more convenient
- Automatically updates local branch
- May immediately create merge conflicts
Main Difference βοΈ
| Command | Downloads Changes | Automatically Merges | Safer for Review |
|---|---|---|---|
git fetch | β | β | β |
git pull | β | β | β |
When to Use Each π οΈ
Use fetch
- when checking remote changes first
- when working carefully in team projects
- before manual merge or rebase
Use pull
- when quickly syncing repositories
- when automatic merge is acceptable
- during routine collaboration updates
Learning Objectives: Git Advanced & AI π―
- 1. Temporary Storage (
git stash) ποΈβ³- Learn to temporarily shelve uncommitted work to quickly switch branches without forcing a commit.
- 2. Git Recovery & Exclusion (
reset/revert/.gitignore) ππ‘Target- Contrast
git reset(rewinding history) withgit revert(safe history reversal via a new commit). - Configure a
.gitignorefile to exclude build artifacts and secrets from version tracking.
- Contrast
- 3. AI-Assisted Development π€π§ͺ
- Integrate AI coding assistants with explicit prompting.
- Develop a validation-first mindset to test and review AI code instead of blindly trusting it.
git stash: Temporary Storage Management ποΈβ³
π¨ Typical Use Scenario: The Production Hotfix
- The Problem: You are deep in the middle of developing a complex new feature on a branch. Your code is currently broken, experimental, and incomplete. Suddenly, a critical bug is discovered in production that requires an immediate hotfix on the
mainbranch. - The Conflict: Git will block you from switching branches (
git checkout main) if your uncommitted local changes conflict with the target branch, and you do not want to rungit commitbecause your feature code is unstable and half-written. - The Solution: Running
git stashsafely lifts your modified, uncommitted work out of the directory and stores it on an internal stack. Your working tree becomes completely clean, letting you switch tomain, apply the emergency patch, and then return later to seamlessly retrieve your feature draft.
β¨οΈ Main Commands & Operations
git stash: Takes all current modifications in your working directory and staging area, moves them onto the stash stack, and resets the local directory back to a cleanHEADstate.git stash push -m "name": The modern, explicit syntax used to save changes with a descriptive label. This custom identifier makes it much easier to distinguish between different saved states when managing a large stack.git stash list: Outputs a structured chronological list of all saved stash items currently stored on your stack (formatted as a zero-indexed tracking layout:stash@{0},stash@{1}, etc.).git stash show -p: Generates a detailed, line-by-line patch comparison (p) showing the exact code changes hidden inside a specific stash entry.
π Restoring and Purging the Stack
git stash popπΏ: Extracts the modifications from the top item (stash@{0}) or a specified index, applies them back into your working directory, and automatically deletes that entry from the stash stack.git stash applyπ: Re-integrates the stashed changes back into your working workspace exactly likepop, but safely leaves the original copy intact on the stash stack for future use or cross-branch testing.git stash drop stash@{0}ποΈ: Permanently deletes a single, specific stash entry from the tracking list without applying any of its code modifications to your project directory.git stash clearπ§Ή: Wipes out the entire stash storage area simultaneously, permanently deleting all saved entries.
Git Reset vs. Revert: Undoing Changes πβ οΈ
β³ History Modification: git reset
git reset rewinds your current branch pointer to a previous commit, changing the timeline.
- The Collaboration Rule: Because
git resetalters the commit history, it can cause sync issues for your team if applied to commits that are already pushed to a shared remote repository. Only usegit resetfor local, unpushed cleanup tasks.
The Three Reset Modes
The syntax relies on explicit flags to determine what happens to your pending changes in the Staging Area and Working Directory:
$ git reset [--mode] [Commit_Hash]
-softMode (Keep Changes Staged) π’: Moves the history pointer back, but preserves all your code changes safely inside the Staging Area. Useful for squashing commits.-mixedMode (Unstage Changes - Default) π‘: Moves the history pointer back and resets the Staging Area, but leaves your files intact in the Working Directory. Changes become unstaged modifications.-hardMode (Absolute Destruction) π΄: Moves the history pointer back and wipes out both the Staging Area and Working Directory to match the target commit precisely. Uncommitted or reset changes are permanently erased.
π‘οΈ Safe History Reversal: git revert
git revert rolls back a commitβs changes by creating a new commit that does the opposite, leaving the past timeline intact.
$ git revert [Commit_Hash_To_Undo]
- How it Works: Instead of deleting anything from the timeline,
git revertlooks at the target commit, determines what lines were added or removed, and applies a new inversion commit that neutralizes those changes. - Safe for Collaboration: Because it only appends a new commit to the end of the history,
git revertis completely safe to use on public, shared remote branches. It resolves errors cleanly without causing history conflicts for other developers.
π Summary: Reset vs. Revert
| Feature | git reset | git revert |
|---|---|---|
| Action | Deletes/Rewinds commits | Creates a new inverse commit |
| Timeline Alteration | Alters history (Destructive) | Appends history (Safe) |
| Best Workspace | Local, unpushed branches only | Shared, public remote branches |
File Tracking Exclusion: .gitignore Rules π‘οΈπ«
π‘ Why Exclusion is Mandatory
In a real software engineering workspace, not every file in your folder belongs in a shared source repository. Checking in everything clutters history, inflates directory sizes, and exposes vulnerabilities.
Core Exclusion Categories:
- Security Credentials & Secrets: Private API keys, database credentials, ssh configurations, and environment configuration values (e.g.,
.env). - Local Workspace Layouts: IDE configurations or user preference settings (e.g.,
.vscode/,.idea/,.suo) that vary from programmer to programmer. - Build Artifacts & Generated Files: Compiled binaries, build directories, or node dependency frameworks (e.g.,
node_modules/,target/,.exe,.log) that can easily be regenerated via build tools.
β¨οΈ Structural Syntax & Pattern Rules
The .gitignore engine uses an adaptive text-pattern syntax called globbing to map files:
# 1. Specific Single File Exclusion
secret_token.txt
# 2. Entire Directory Exclusion (trailing slash)
node_modules/
dist/
# 3. Extension Wildcard Pattern (any file ending with this extension)
*.log
*.tmp
# 4. Inversion / Exception Whitelisting (negation mark)
!important.log
secret_token.txt: Completely hides a single, explicit file anywhere inside the workspace.node_modules/: Recursively targets and blocks an entire directory and all files nested inside it..log: Uses the wild card asterisk () to target any file matching the specified extension, regardless of which subdirectory it lives in.!important.log: Uses an exclamation mark (!) to create a whitelist rule override. This forces Git to trackimportant.logeven if a previous rule (like.log) explicitly hidden it.
β οΈ The Golden Rule of .gitignore
β
.gitignoreonly blocks untracked files!β
If a file has already been added and committed to the repository history in the past, adding its name to .gitignore later will do absolutely nothing. Git already tracks it, so it will continue monitoring adjustments.
How to fix an already-tracked file:
If you accidentally committed a secret file or massive cache folder before adding it to your ignore list, you must manually strip it from Gitβs tracking engine using the cached removal flag before the ignore rules can apply:
# Untracks the file from the index while keeping your actual local copy safe
$ git rm --cached secret_token.txt
# Commit the removal to freeze tracking, then append to .gitignore
$ git commit -m "chore: untrack sensitive credential file"
Git Commit Message Conventions πβ¨
A commit message is more than just a random text blockβit serves as the structural documentation of a repositoryβs evolution. Adhering to professional commit conventions ensures automated changelog generation, easy filtering with git log, and seamless code reviews across teams.
ποΈ The Standard 3-Part Structural Layout
A formal commit message follows a strict hierarchical layout composed of a Header, an optional Body, and an optional Footer:
type: Subject line summarizes changes in under 50 characters
[Optional Body]
Detailed explanation describing the conceptual "why" behind the change,
not the "what" (the code diff tells you the what). Wrap lines at 72 characters.
[Optional Footer]
Resolves: #128 (Issue tracker tracking references or breaking changes)
- Header (Subject Line): A single concise phrase containing the prefix classification and short title.
- Body: Used for substantial adjustments requiring context. It clarifies the engineering motive and logic.
- Footer: Used to reference tracking tickets (e.g., Jira, GitHub issues) or call out breaking changes.
π·οΈ Prefixes: Commit Classification Types
To achieve standard semantic versioning, every commit summary must begin with a standardized classification keyword detailing the precise nature of the change:
| Type | Intended Purpose | Real-World Example |
|---|---|---|
feat | Production introduction of a completely new feature or tool | feat: add user authentication endpoint |
fix | Direct bug resolution or error patching | fix: prevent null pointer exception on logout |
docs | Changes confined strictly to documentation files (like README.md) | docs: add deployment steps to readme |
style | Code adjustments that do not affect operational logic (white-space, formatting, linting) | style: run prettier formatter on checkout component |
refactor | Operational code modifications that neither fix bugs nor add new features | refactor: extract duplicate validation into helper function |
test | Introducing new test modules or fixing existing test coverage | test: add unit tests for daily backup routine |
chore | Routine workspace changes, auxiliary dependencies, or build tool adjustments | chore: untrack sensitive credential file |
π The 5 Golden Rules of Writing Effective Commits
- Rule 1: Separate Subject from Body with a Blank Line Gitβs parsing engines utilize the initial empty line break to cleanly distinguish the shorthand subject line header from the verbose body paragraph.
- Rule 2: Limit the Subject Line to 50 Characters Keep headers crisp and compact. This ensures messages do not get truncated or overflow when rendering in short-log repository summaries or UI interfaces.
- Rule 3: Do Not End the Subject Line with a Period A subject line acts as an active title card or command string. Eliminating trailing punctuation keeps lines clean.
- Rule 4: Use Imperative Mood in the Subject Line Write your subject line as a direct command stating what the commit does, not what it did.
- β Incorrect:
fixed user session timeout bugorfeat: adds verification - π’ Correct:
fix: resolve user session timeout bugorfeat: add verification
- β Incorrect:
- Rule 5: Use the Body to Focus on βWhyβ and βHowβ, Not βWhatβ The actual programmatic file diff inherently displays what lines changed. The commit body paragraph exists to preserve the developerβs architectural reasoningβexplaining why a particular path was selected and how it fixes the underlying constraint.
