Skip to content

Linux Git Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

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

  1. Git Installation
  2. Git Configuration
  3. Basic Git Commands
  4. Branching
  5. Remote Repositories
  6. Troubleshooting

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 "your.email@example.com"

# 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:

  1. Open conflicted file
  2. Edit to resolve
  3. Add file
  4. Commit merge

Summary

This guide covered Git installation, configuration, and basic usage for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally