Linux Git Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux Git Guide
Complete beginner-friendly guide to Git on Linux, covering Arch Linux, CachyOS, and other distributions including installation, basic usage, branching, and version control.
Table of Contents
Git Installation
Install Git
Arch/CachyOS:
# Install Git
sudo pacman -S git
# With GUI tools
sudo pacman -S git git-gui gitk
Debian/Ubuntu:
sudo apt install git
Fedora:
sudo dnf install git
Verify Installation
Check Git:
# Check version
git --version
# Check configuration
git config --list
Git Configuration
Initial Setup
Configure Git:
# Set user name
git config --global user.name "Your Name"
# Set email
git config --global user.email "[email protected]"
# Set default editor
git config --global core.editor vim
View Configuration
Check settings:
# List all config
git config --list
# Check specific setting
git config user.name
Basic Git Commands
Initialize Repository
Create repository:
# Initialize repo
git init
# Or clone existing
git clone https://github.com/user/repo.git
Basic Workflow
Common commands:
# Check status
git status
# Add files
git add file.txt
git add . # All files
# Commit
git commit -m "Commit message"
# View history
git log
Branching
Create Branch
Branch operations:
# Create branch
git branch new-branch
# Switch branch
git checkout new-branch
# Or create and switch
git checkout -b new-branch
Merge Branches
Merge:
# Switch to main branch
git checkout main
# Merge branch
git merge new-branch
Remote Repositories
Add Remote
Connect to remote:
# Add remote
git remote add origin https://github.com/user/repo.git
# View remotes
git remote -v
Push/Pull
Sync with remote:
# Push to remote
git push origin main
# Pull from remote
git pull origin main
Troubleshooting
Git Errors
Common issues:
# Check Git status
git status
# View Git log
git log --oneline
# Reset changes
git reset --hard HEAD
Merge Conflicts
Resolve conflicts:
- Open conflicted file
- Edit to resolve
- Add file
- Commit merge
Summary
This guide covered Git installation, configuration, and basic usage for Arch Linux, CachyOS, and other distributions.
Next Steps
- Development Environment - Development setup
- VS Code Guide - VS Code setup
- Git Documentation: https://git-scm.com/
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.