πŸ‘€ Git on Debian: A Complete Setup and Workflow Guide (2025 Edition)

Date Created: 2025-05-27
By: 16BitMiker
[ BACK.. ]

Whether you're managing your own codebase or collaborating via a self-hosted Gitea instance, Git remains the cornerstone of modern development workflows. This guide offers a comprehensive, up-to-date walkthrough for setting up Git on Debian, connecting to Gitea via SSH, and mastering the six most essential Git commands. Let's get you running efficiently and securely. πŸ”οΈ

πŸ“‹ Git Installation on Debian

For most users, Debian's stable packages are more than sufficient:

πŸ“¦ Compile from Source (Advanced)

For the latest Git features or when you're customizing the build:

πŸ“‹ Configure Git for Daily Use

πŸ› οΈ Set Identity and Preferences

πŸ“‹ SSH Key Setup for Gitea

SSH is the preferred method for secure Git access.

In Gitea:

  1. Go to Settings β†’ SSH/GPG Keys

  2. Click β€œAdd Key” β†’ Paste your public key

  3. Save with a descriptive name

Test SSH connection:

πŸ”„ Create Repository in Gitea

πŸ”„ Initialize Locally

πŸ“‹ Six Essential Git Commands

βœ… 1. git status – Inspect Your Workspace

Helps you track staged, unstaged, and untracked changes.

βœ… 2. git add – Stage Changes

Tip: Use git add -p to review changes before staging.

βœ… 3. git commit – Save to Local History

Write clear, imperative commit messages:

βœ… 4. git push – Upload to Remote

Always pull before you push to avoid merge conflicts.

βœ… 5. git pull – Download and Merge Updates

Tip: Set git config pull.rebase true for a cleaner commit history.

βœ… 6. git clone – Copy a Remote Repository

Use HTTPS only if SSH access is not available.

πŸ“‹ Daily Git Workflow Example

πŸš€ From start to finish in a real-world scenario:

πŸ“‹ Git Power Features

πŸ”§ Git Aliases to Save Time

Now you can run git st, git ci -m "...", or git graph.

πŸ”§ .gitignore Setup

Avoid committing temp files or build artifacts:

Add language- and tool-specific entries as needed.

πŸ”§ Git Hooks for Automation

Create a pre-commit hook to enforce standards:

Make it executable:

πŸ“‹ Troubleshooting and Optimization

πŸ› οΈ SSH Key Issues

πŸ› οΈ Merge Conflicts

Use git mergetool for assisted resolution.

πŸ› οΈ Undo Mistakes

Be cautious with --hard as it deletes changes permanently.

πŸ› οΈ Maintenance

πŸ‘₯ Security Best Practices

πŸ” GPG Commit Signing

To sign commits manually:

πŸ” Secure Git Configuration

πŸ“š Read More

Mastering Git on Debian with Gitea integration sets you up for collaborative coding success. With secure SSH access, a clean commit history, and automation via hooks and aliases, you can focus more on building and less on battling your tools. βœ…

Happy hacking! πŸ’»