How to Build a Full Git Version‑Control Environment
This guide walks through installing Git, configuring user information and SSH keys for GitHub/GitLab, recommends graphical clients, and provides a concise cheat sheet of essential Git commands to help you manage code, documents, and configuration files effectively.
1. Install Git
sudo apt update
sudo apt install git2. Initial configuration
Set the user name and email so they appear in every commit record.
git config --global user.name "Your Name"
git config --global user.email "[email protected]"Check the configuration: git config --list Optional but useful settings:
git config --global init.defaultBranch main
git config --global core.editor "nano"3. Configure SSH key (connect to GitHub/GitLab)
Generate an SSH key to avoid entering a password for each push.
ssh-keygen -t ed25519 -C "[email protected]"You can press Enter through the prompts or add a passphrase for extra protection.
View the public key: cat ~/.ssh/id_ed25519.pub Copy the output that starts with ssh-ed25519 and add it to GitHub under Settings → SSH and GPG keys → New SSH key.
Test the connection: ssh -T [email protected] If you see “Hi username! You've successfully authenticated…”, the setup succeeded.
4. Common graphical Git clients
Although the command line is the fastest, GUIs make complex merge conflicts and history inspection more intuitive.
GitKraken : visually appealing and feature‑rich (some advanced features require payment).
VS Code : built‑in Git support; with the "Git Graph" extension it handles most scenarios.
Sublime Merge : extremely fast and lightweight.
5. Frequently used commands cheat sheet
git init: initialize a repository. git clone <url>: clone a remote repository. git status: view current status. git add .: stage all modifications. git commit -m "msg": commit changes. git pull: fetch and merge remote changes. git push: push commits to remote. git checkout -b <branch>: create and switch to a new branch.
Recommended habit: run git status before each commit to ensure you are committing exactly what you intend, not stray temporary files.
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.
Ubuntu
Focused on Ubuntu/Linux tech sharing, offering the latest news, practical tools, beginner tutorials, and problem solutions. Connecting open-source enthusiasts to build a Linux learning community. Join our QQ group or channel for discussion!
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.
