AI Study Online
AI Tutorials

Complete Practical Guide to Using GitHub Repositories for Global Independent Developers

5 min read

1. Preparatory Environment Setup

First complete Git local installation and global configuration before operating GitHub repositories.

Install Git on mainstream OS

# Ubuntu / Debian Linux
sudo apt update && sudo apt install git -y

# MacOS via Homebrew
brew install git

# Windows users download official installer from git-scm.com and complete default setup

Global user information configuration (bind GitHub account)

# Replace with your registered GitHub mailbox and username
git config --global user.name "YourGithubName"
git config --global user.email "yourmail@example.com"

# Verify configuration result
git config --global --list

2. Three Common Ways to Obtain Remote GitHub Repository Code

Method 1: Clone full repository to local

# HTTPS clone (universal for all networks)
git clone https://github.com/UserName/TargetRepo.git

# SSH clone (recommended after configuring SSH key, no repeated password input)
git clone git@github.com:UserName/TargetRepo.git

# Clone specified single branch only to save disk space
git clone -b dev https://github.com/UserName/TargetRepo.git

Method 2: Download ZIP package without Git environment

Visit repository homepage, click Code, then Download ZIP. Suitable for users who only need to browse source code temporarily.

Method 3: Initialize empty local folder and link remote repo

mkdir my-project && cd my-project
git init
git remote add origin https://github.com/UserName/TargetRepo.git
git pull origin main

3. Core Local Code Commit and Push Workflow

Standard four-step submission process for code modification, the most frequently used daily operation for developers:

# Step 1: Track all newly added/modified files under current directory
git add .

# Step 2: Write commit remark (use English description for international open source standard)
git commit -m "feat: add overseas multi-language config file"

# Step 3: Pull latest remote code to avoid conflict before upload
git pull origin main

# Step 4: Push local commits to remote main branch of GitHub
git push origin main

Specification tip: Follow Angular commit standard for remarks: feat (new feature) / fix (bug fix) / docs (document update), convenient for subsequent version iteration.

4. Branch Management for Team Collaborative Development

Multi-branch is the core of team co-development, avoid direct modification on main production branch:

# Create new feature branch and switch into it immediately
git checkout -b feature/europe-market

# Check all existing local branches
git branch

# After finishing development on feature branch, switch back to main
git checkout main

# Merge completed feature branch into main branch
git merge feature/europe-market

# Delete useless local feature branch after merge
git branch -d feature/europe-market

# Push new remote branch to GitHub
git push origin feature/europe-market

5. Practical Tips for Overseas Developers

5.1 Generate SSH key to skip repeated password verification

# Generate RSA SSH key, bind your GitHub mailbox
ssh-keygen -t ed25519 -C "yourmail@example.com"

Copy content inside ~/.ssh/id_ed25519.pub, paste into GitHub account Settings > SSH and GPG keys to finish binding.

5.2 Ignore redundant files via .gitignore file

Create .gitignore at project root to exclude cache, environment configuration and dependent folders from upload:

# Sample .gitignore content for Node.js project
node_modules/
.env
*.log
.DS_Store
dist/

5.3 Switch remote repository address (transfer repo to new Github account)

git remote set-url origin https://github.com/NewOwner/NewRepoName.git
# Check modified remote address
git remote -v

6. Practical Application Scenarios for Cross-border Projects

  1. Open-source tool secondary development: Clone open-source warehouse, create independent feature branch, modify code, submit PR to original author for merge.
  2. Overseas website version iteration: Maintain main as online production code, develop new regional features on independent branches.
  3. Team distributed collaboration: Remote members pull main branch regularly, develop on personal branch and submit PR for administrator review.

Final Troubleshooting for Common Errors

  • Push failure due to code conflict: Execute git pull origin main first to merge remote content then push again.
  • Accidental wrong commit modification: git commit --amend modify latest commit comment without creating new record.
Share this article

Related Articles

AI TutorialsBeginner

How to Write Prompts That Actually Work: The 5-Point Framework

Vague prompts get mediocre answers. Master the 5-Point Prompt Framework — Role, Context, Task, Format, Constraints — and get dramatically better results from any AI tool.

5 min read
PromptsPrompt EngineeringFramework