
SourceTree and Git Setup
Setup •
Version 1.0.0 •
SourceTree and Git Setup Guide
This comprehensive guide will walk you through setting up SourceTree and Git for your Astro Modular blog, enabling seamless version control and deployment workflows.
Prerequisites
Before starting, ensure you have:
- A GitHub account
- Your Astro Modular blog project ready
- Basic understanding of version control concepts
Step 1: Install Git
Windows
- Download Git from git-scm.com
- Run the installer with default settings
- Verify installation: Open Command Prompt and run
git --version
macOS
- Install Xcode Command Line Tools:
xcode-select --install
- Or download from git-scm.com
- Verify installation: Open Terminal and run
git --version
Linux
# Ubuntu/Debian
sudo apt update
sudo apt install git
# CentOS/RHEL
sudo yum install git
# Verify installation
git --version
Step 2: Configure Git
Set up your Git identity:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Optional: Set up SSH keys for GitHub
- Generate SSH key:
ssh-keygen -t ed25519 -C "your.email@example.com"
- Add to SSH agent:
ssh-add ~/.ssh/id_ed25519
- Copy public key:
cat ~/.ssh/id_ed25519.pub
- Add to GitHub: Settings → SSH and GPG keys → New SSH key
Step 3: Install SourceTree
Download and Install
- Visit sourcetreeapp.com
- Download the free version
- Install with default settings
- Sign in with your Atlassian account (free)
First Launch Setup
- Choose “I don’t have a repository yet”
- Connect your GitHub account
- Authorize SourceTree to access your repositories
Step 4: Initialize Your Blog Repository
Option A: Create New Repository on GitHub
- Go to GitHub.com → New Repository
- Name it
your-blog-name
- Make it public or private
- Don’t initialize with README (we’ll do this locally)
Option B: Use Existing Repository
If you already have a repository, skip to Step 5.
Step 5: Clone Repository in SourceTree
- Open SourceTree
- Click “Clone” button
- Enter your repository URL:
- HTTPS:
https://github.com/username/your-blog-name.git
- SSH:
git@github.com:username/your-blog-name.git
- HTTPS:
- Choose local folder for your project
- Click “Clone”
Step 6: Set Up Your Astro Blog
Copy Your Blog Files
- Copy all your Astro Modular files into the cloned repository folder
- Ensure you have:
src/
directory with your contentpackage.json
andpnpm-lock.yaml
astro.config.mjs
- All other necessary files
Initial Commit
- In SourceTree, you’ll see all your files listed as “Unstaged files”
- Click “Stage All” to add all files to staging
- Write a commit message: “Initial blog setup”
- Click “Commit”
- Click “Push” to upload to GitHub
Step 7: Configure Deployment
For Netlify
- Go to netlify.com
- Connect your GitHub account
- Select your blog repository
- Build settings:
- Build command:
pnpm run build
- Publish directory:
dist
- Build command:
- Deploy!
For Vercel
- Go to vercel.com
- Import your GitHub repository
- Framework preset: Astro
- Deploy!
Step 8: Daily Workflow with SourceTree
Making Changes
- Edit your blog content in Obsidian or your editor
- Open SourceTree
- Review changes in the “Working Directory” tab
- Stage specific files or “Stage All”
- Write descriptive commit message
- Click “Commit”
- Click “Push” to sync with GitHub
Best Practices
- Commit frequently: Small, focused commits are better
- Write clear messages: “Add new blog post about X” not “Update files”
- Pull before pushing: Always pull latest changes first
- Use branches: Create feature branches for major changes
Step 9: Advanced Git Workflows
Creating Branches
- In SourceTree, click “Branch” → “New Branch”
- Name it descriptively:
feature/new-theme
orfix/typo-correction
- Make your changes
- Commit and push the branch
- Create Pull Request on GitHub
Merging Changes
- Switch to main branch
- Pull latest changes
- Merge your feature branch
- Delete the feature branch
Resolving Conflicts
- SourceTree will show conflict markers
- Edit files to resolve conflicts
- Stage resolved files
- Commit the resolution
Step 10: Backup and Recovery
Regular Backups
- Your code is automatically backed up on GitHub
- Consider additional backups of your content
- Use Git’s built-in history for recovery
Recovering from Mistakes
- Undo last commit: Right-click commit → “Reset current branch to this commit”
- Revert changes: Right-click file → “Discard changes”
- View history: Click on any commit to see what changed
Troubleshooting Common Issues
Authentication Problems
- HTTPS: Use Personal Access Token instead of password
- SSH: Ensure SSH key is added to GitHub account
Merge Conflicts
- Don’t panic! Conflicts are normal
- Read the conflict markers carefully
- When in doubt, ask for help
Large Files
- Git isn’t designed for large binary files
- Use Git LFS for images and videos
- Or store assets externally (CDN, etc.)
Repository Size
- Use
.gitignore
to exclude unnecessary files - Clean up history if repository becomes too large
Integration with Obsidian
Git Integration in Obsidian
- Install “Obsidian Git” plugin
- Configure auto-commit settings
- Your Obsidian vault changes will be automatically committed
Workflow
- Write in Obsidian
- Obsidian Git auto-commits changes
- SourceTree pulls and pushes to GitHub
- Netlify/Vercel auto-deploys
Next Steps
Once you have Git and SourceTree set up:
- Explore SourceTree features: Learn about stashing, cherry-picking, and rebasing
- Set up CI/CD: Automate your deployment pipeline
- Collaborate: Invite others to contribute to your blog
- Backup strategies: Implement additional backup solutions
Getting Help
- SourceTree Documentation: confluence.atlassian.com
- Git Documentation: git-scm.com/doc
- GitHub Help: docs.github.com
Remember: Git and SourceTree are powerful tools that will make managing your blog much easier. Take time to learn the basics, and don’t hesitate to experiment in a test repository first!