Project Task 2: Working with Remotes
Continue building your portfolio project by mastering remote management.
Objective
Configure multiple remotes and understand different URL formats.
Prerequisites
You should have completed Task 1 with your portfolio project.
Instructions
Step 1: Verify Current Remote
bash
1cd portfolio-project
2
3# Check current remote
4git remote -v
5
6# Should show:
7# origin https://github.com/username/portfolio-project.git (fetch)
8# origin https://github.com/username/portfolio-project.git (push)Step 2: View Remote Details
bash
1git remote show origin
2
3# Note the information displayed:
4# - Fetch/Push URLs
5# - HEAD branch
6# - Remote branchesStep 3: Add SSH Remote (Alternative Access)
bash
1# Add same repo with SSH URL as alternate
2git remote add github-ssh git@github.com:username/portfolio-project.git
3
4# Verify both
5git remote -v
6
7# Output:
8# github-ssh git@github.com:username/portfolio-project.git (fetch)
9# github-ssh git@github.com:username/portfolio-project.git (push)
10# origin https://github.com/username/portfolio-project.git (fetch)
11# origin https://github.com/username/portfolio-project.git (push)Step 4: Understand When to Use Each
HTTPS (origin):
- Works through firewalls
- Requires credentials/token
- Good for beginners
SSH (github-ssh):
- No password prompts
- Requires SSH key setup
- Preferred for regular use
Step 5: Switch Primary Remote to SSH
If you've set up SSH keys:
bash
1# Change origin to SSH
2git remote set-url origin git@github.com:username/portfolio-project.git
3
4# Remove the extra remote
5git remote remove github-ssh
6
7# Verify
8git remote -vStep 6: Make and Push Changes
bash
1# Add new section to index.html
2cat >> index.html << 'EOF'
3 <section id="projects">
4 <h2>My Projects</h2>
5 <ul>
6 <li>Portfolio Website</li>
7 <li>More coming soon...</li>
8 </ul>
9 </section>
10EOF
11
12# Stage and commit
13git add index.html
14git commit -m "Add projects section"
15
16# Push to remote
17git push origin mainStep 7: Verify on GitHub
- Visit your repository on GitHub
- Check that the new commit appears
- View the updated index.html file
Bonus: Add a Mirror Remote
For backup purposes, you can push to multiple remotes:
bash
1# Add a GitLab mirror (optional)
2# First create repo on GitLab, then:
3git remote add gitlab https://gitlab.com/username/portfolio-project.git
4
5# Push to both
6git push origin main
7git push gitlab mainVerification Checklist
- Remote shows correct URL
- Can view remote details with
git remote show - Changes pushed successfully
- Commits visible on GitHub
Common Issues
Authentication Failed
bash
1# For HTTPS, use a Personal Access Token
2# GitHub → Settings → Developer Settings → Personal Access Tokens
3
4# Or switch to SSH
5git remote set-url origin git@github.com:username/repo.gitRemote Already Exists
bash
1# Remove and re-add
2git remote remove origin
3git remote add origin <correct-url>
4
5# Or just update URL
6git remote set-url origin <correct-url>Summary
In Task 2, you learned:
- ✅ How to view remote details
- ✅ HTTPS vs SSH remotes
- ✅ How to change remote URLs
- ✅ Pushing changes to remotes
Next: Learn about push and pull commands in detail!
