_____ _ _
/ ____(_) |
| | __ _| |_
| | |_ | | __|
| |__| | | |_
\_____|_|\__|
🚀 Basic Git Workflow
# Check status of your repo $ git status # Add all changes $ git add . # Add specific file $ git add filename.html # Commit with message $ git commit -m "Your commit message here" # Push to remote $ git push origin main
🔄 Pulling & Syncing
# Pull latest changes $ git pull origin main # Pull and allow unrelated histories $ git pull origin main --allow-unrelated-histories # Pull from pages branch $ git pull origin pages
🌿 Branch Operations
# List all branches $ git branch # Switch to existing branch $ git checkout pages # Create and switch to new branch $ git checkout -b new-branch-name # Merge another branch into current $ git merge main # Merge with unrelated histories $ git merge main --allow-unrelated-histories
⚔️ Conflict Resolution
# Keep YOUR version (local) during merge conflict $ git checkout --ours . $ git add . $ git commit -m "Resolved conflicts - kept local version" # Keep THEIR version (remote) during merge conflict $ git checkout --theirs . $ git add . $ git commit -m "Resolved conflicts - kept remote version" # Abort a merge $ git merge --abort
🗑️ Removing Files
# Remove file from Git tracking (keep locally) $ git rm --cached filename # Remove folder from Git tracking $ git rm --cached -r foldername/ # Remove and delete file $ git rm filename # Force remove $ git rm -rf .forgejo
💪 Force Operations
⚠️ Warning: Force operations can overwrite history and cause data loss. Use with extreme caution and only when you know what you're doing!
# Force push (overwrites remote) $ git push origin main --force # Force add (ignores .gitignore) $ git add -f public/
📦 Submodule Operations
# Remove submodule from tracking $ git rm --cached themes/golden-thread # Delete submodule's .git folder (PowerShell) $ Remove-Item -Recurse -Force themes/golden-thread/.git # Delete submodule's .git folder (Bash) $ rm -rf themes/golden-thread/.git
🌐 Codeberg Pages Workflow
💡 Key Insight: Codeberg Pages serves from the
pages branch, not main. You must merge your changes from main → pages for them to appear on your website.
# Standard workflow for Codeberg Pages # 1. Work on main branch $ git checkout main $ git add . $ git commit -m "Update content" $ git push origin main # 2. Merge to pages branch (what Codeberg serves) $ git checkout pages $ git merge main --allow-unrelated-histories $ git push origin pages # 3. Wait 1-2 minutes for Codeberg to rebuild
🔧 Hugo Commands
# Build Hugo site locally $ hugo # Build with minification $ hugo --minify # Serve locally for testing $ hugo server # Serve with drafts visible $ hugo server -D
📝 Vim Quick Commands
When Git opens Vim for commit messages:
# Save and quit :wq # Quit without saving :q! # Force save and quit :wq!
🐛 Common Issues & Fixes
"Updates were rejected because the remote contains work"
$ git pull origin main $ git push origin main
"refusing to merge unrelated histories"
$ git merge main --allow-unrelated-histories
"Merge conflict in file.html"
# Keep your version $ git checkout --ours . $ git add . $ git commit -m "Resolved conflicts"
"Authentication failed"
- Use lowercase username:
ropanotROPA - Use personal access token instead of password
- Check your token hasn't expired
"404 Not Found on Codeberg Pages"
- Check files are in
pagesbranch (notmain) - Wait 1-2 minutes after pushing
- Verify files are in repo root, not subfolder
- Check file names are correct (case-sensitive!)
🎯 Quick Reference Table
| Command | What It Does |
|---|---|
git status |
Check what's changed |
git add . |
Stage all changes |
git commit -m "msg" |
Save changes with message |
git push origin main |
Upload to main branch |
git push origin pages |
Upload to pages branch (for Codeberg) |
git pull origin main |
Download latest changes |
git checkout branch |
Switch branches |
git merge branch |
Merge another branch |
git rm --cached file |
Stop tracking file |
💡 Pro Tips
- Always check status first: Run
git statusbefore doing anything to see what's changed - Commit often: Small, frequent commits are better than huge ones
- Write clear messages: "Fix bug" ❌ vs "Fixed navbar overlap on mobile" ✅
- Test locally first: Use
hugo serverbefore pushing to production - Keep main and pages in sync: Regularly merge main → pages for Codeberg
- Use branches: Create feature branches for experimental work
- Read the error messages: Git's errors are usually helpful!
_____ _ _
/ ____| | | | |
| | ___ _ __ ___ | | ___| |_
| | / _ \| '_ ` _ \| |/ _ \ __|
| |___| (_) | | | | | | | __/ |_
\_____\___/|_| |_| |_|_|\___|\__|