Git Installation and Basic Usage Guide
This article introduces Git as a distributed version‑control tool, explains what it does, walks through installing it on Windows, macOS, and Linux, shows how to configure a user name and email, and provides the essential commands for initializing repositories, committing changes, and working with remote repositories.
Git is a distributed version‑control system often likened to a "code time machine"; it records every change, enables multiple developers to collaborate, and allows easy rollback of problematic revisions.
What is Git
From a conceptual standpoint, Git manages code versions and helps teams work together efficiently.
Installation
Windows
Visit the official Git website.
Download the Windows installer.
Run the installer and follow the default prompts.
After installation, open Git Bash.
Verify the installation with git --version.
macOS
Git can be installed via two common methods:
Install Xcode Command Line Tools.
Use Homebrew: brew install git and then verify with git --version.
Linux
Most distributions provide Git through their package managers.
Ubuntu/Debian: sudo apt update then sudo apt install git.
CentOS: sudo yum install git.
After installation, run git --version to confirm.
Basic Configuration
After the first installation, set your identity:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"These details are attached to every commit you make.
Common Git Commands
git init– Initialize a new repository in the current directory. git status – Show changed, staged, and untracked files. git add . – Stage all modified files for commit. git commit -m "message" – Record staged changes with a message. git log --oneline – List commit history in a compact form.
Remote Repository Operations
git remote add origin <repo‑url>– Link a local repo to a remote. git push -u origin main – Push local commits to the remote main branch. git pull – Fetch and merge changes from the remote. git clone <repo‑url> – Clone an existing remote repository.
Typical Workflow
The most common sequence for everyday development is:
git init
git add .
git commit -m "Initial commit"
git push -u origin mainThis covers creating a repository, staging changes, committing them, and pushing to a remote server.
Conclusion
Git is not as intimidating as it may seem. Beginners only need to master the basic commands and workflow to handle most development scenarios, whether working on personal projects or collaborating in a team.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Network Intelligence Research Center (NIRC)
NIRC is based on the National Key Laboratory of Network and Switching Technology at Beijing University of Posts and Telecommunications. It has built a technology matrix across four AI domains—intelligent cloud networking, natural language processing, computer vision, and machine learning systems—dedicated to solving real‑world problems, creating top‑tier systems, publishing high‑impact papers, and contributing significantly to the rapid advancement of China's network technology.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
