Git Essentials on Ubuntu: A Practical Command-Line Guide

Overview

Mastering version control begins right inside the Linux terminal. This practical walkthrough guides you through installing Git on an Ubuntu system and navigating everyday repository workflows. From provisioning a local repository and tracking revisions to managing isolated branches and merging feature updates, this tutorial establishes the foundational skills necessary for professional software engineering.

Installing Git and Establishing Global User Settings

Before running any version control operations, refresh Ubuntu’s local APT package index and install the Git suite.

apt-get update -qq && apt-get install -y git

Verify that the binary deployed correctly by querying its release version.
⚙️ [Core Options]

--version : Displays the currently installed Git software release.
--help : Launches reference documentation detailing common usage patterns and commands.
-C <경로> : Directs the command to execute within the designated directory target.
-c <설정명>=<값> : Applies a transient configuration variable for a single execution cycle.

git –version

Associate your identity with future revisions by recording a global author name using git config --global user.name.

git config –global user.name “Dev User”

Assign an email address to your global profile so commits correctly reflect your developer contact information via git config --global user.email.

git config –global user.email “user@example.com”

Review all active system, global, and local configuration values to ensure your author identity was properly stored.

git config –list

Initializing a Repository and Recording Your First Commit

Create an isolated practice folder and navigate directly into it using mkdir -p ~/git_practice && cd ~/git_practice.

mkdir -p ~/git_practice && cd ~/git_practice

Turn this directory into an active Git tracking workspace with git init.
This command generates an internal, hidden .git folder responsible for storing snapshots and repository metadata.

git init

Create a sample markdown file to serve as initial project documentation using the standard echo command.

echo “Git practice repository on Ubuntu” > README.md

Inspect the working tree and staging index to evaluate modified or untracked assets via git status.

git status

Stage the newly created README.md file into the index to mark it for the upcoming commit using git add README.md.

git add README.md

Permanently record the staged snapshot into the project history alongside an informative summary using git commit -m "Initial commit: add README.md".

git commit -m “Initial commit: add README.md”

Tracking Working Tree Modifications and Reviewing History

Simulate ongoing documentation work by appending an extra line to the existing file via echo "Project documentation update" >> README.md.

echo “Project documentation update” » README.md

Add a new Python script to the project structure to serve as application logic with echo "print('Hello Linux')" > app.py.

echo “print(‘Hello Linux’)” > app.py

View working tree changes in a condensed, high-density format by running git status -s.
Modified files are tagged with M, while newly created, untracked files display ??, allowing quick visual triage.

git status -s

Analyze unstaged line-by-line differences against the previous commit state using git diff.
This inspection allows you to review added and removed code segments before staging your work.

git diff

Stage all pending file modifications and brand-new files in a single pass with git add ..

git add .

Snapshot all indexed updates into the timeline with a descriptive message using git commit -m "Update README and create app.py".

git commit -m “Update README and create app.py”

Display revision logs in a compact one-line format accompanied by a visual branch graph via git log --oneline --graph.
Concise commit hashes paired with commit subjects provide a clear architectural perspective of recent project activity.

git log –oneline –graph

Branching Workflows and Clean Merge Operations

Branch out from the current commit to isolate feature development without disturbing the main timeline using git branch feature-service.

git branch feature-service

Switch your active working tree context to the new branch using git checkout feature-service.

git checkout feature-service

Implement mock backend logic for the new capability by generating a service script with echo "Service module implementation" > service.py.

echo “Service module implementation” > service.py

Queue the newly drafted service.py module for tracking via git add service.py.

git add service.py

Save the module implementation into the isolated branch history with git commit -m "Implement service module".

git commit -m “Implement service module”

Return to your prior branch context by passing the dash shortcut with git checkout -.

git checkout -

Integrate the completed work from feature-service into your primary branch while defining an explicit merge notice with git merge feature-service -m "Merge feature-service into base branch".

git merge feature-service -m “Merge feature-service into base branch”

Inspect the comprehensive timeline across all active refs by executing git log --oneline --graph --all.
The graphical tree visualization highlights branch divergence and proves that feature integration completed cleanly.

git log –oneline –graph –all

You now have a solid command-line foundation covering package installation, repository initialization, file staging, and branch merging on Ubuntu.
Replicating these essential Git steps directly inside your terminal ensures seamless version control for any Linux development project.