🏠 Home / Hub

🔶 Git Lesson 04 — Remote & GitHub Setup

← Back to Git Menu  |  🏠 Hub

1. Remote Repository

Remote = cloud ထဲမှာ ရှိတဲ့ repository copy
GitHub / GitLab / Bitbucket = popular remote hosts
"origin" = default remote name (convention)
# View remotes
git remote -v
# origin  https://github.com/user/repo.git (fetch)
# origin  https://github.com/user/repo.git (push)

# Add remote
git remote add origin https://github.com/user/myapp.git

# Change remote URL
git remote set-url origin https://github.com/user/new-repo.git

# Remove remote
git remote remove origin

2. Push & Pull

# First push — set upstream
git push -u origin main
# -u = --set-upstream (subsequent pushes: just "git push")

# Push feature branch
git push origin feature/login

# Pull (fetch + merge)
git pull origin main

# Fetch only (download but don't merge)
git fetch origin
git log origin/main --oneline   # see remote commits
git diff HEAD origin/main       # compare local vs remote

# Pull with rebase (cleaner history)
git pull --rebase origin main

# Set default pull strategy
git config --global pull.rebase false  # merge (default)
git config --global pull.rebase true   # rebase

# Delete remote branch
git push origin --delete feature/old-feature

3. GitHub SSH Setup (No password prompt)

# 1. Generate SSH key
ssh-keygen -t ed25519 -C "ko@example.com"
# Press Enter 3 times (default path, no passphrase)

# 2. View public key
cat ~/.ssh/id_ed25519.pub
# ssh-ed25519 AAAAC3Nza... ko@example.com

# 3. Add to GitHub
# github.com → Settings → SSH Keys → New SSH Key → paste key

# 4. Test connection
ssh -T git@github.com
# Hi ko-username! You've successfully authenticated.

# 5. Use SSH URL (not HTTPS)
git remote set-url origin git@github.com:username/repo.git

# Now push/pull without password!
git push origin main
💡 SSH = once setup → never type password again | HTTPS = need Personal Access Token (2021+)

4. Clone — Download Repository
# Clone — download existing repo
git clone https://github.com/user/repo.git
git clone git@github.com:user/repo.git      # SSH

# Clone to specific folder
git clone https://github.com/user/repo.git myapp

# Clone specific branch only
git clone -b develop https://github.com/user/repo.git

# After clone: remote "origin" is already set!
cd myapp
git remote -v    # origin = source URL

# Shallow clone (large repos — get only recent history)
git clone --depth=1 https://github.com/user/repo.git

5. Daily Remote Workflow

# Morning routine
git switch main
git pull origin main           # get latest changes

# Start feature
git switch -c feature/dashboard

# Work...
git add .
git commit -m "add dashboard layout"
git commit -m "add dashboard charts"

# Push to share / backup
git push origin feature/dashboard

# If main updated while working on feature
git switch main
git pull origin main
git switch feature/dashboard
git rebase main               # replay your commits on top of latest main
# OR:
git merge main                # merge main into your feature

# After PR merged
git switch main
git pull origin main
git branch -d feature/dashboard
git push origin --delete feature/dashboard  # remove remote branch too

← Git 03  |  Next: Git 05 → GitHub Workflow →

📌 Study Checklist