Git and GitHub: How to Create a Repository on GitHub and Associate a Local Project
Git is a version control system that records file modifications and supports multi-person collaboration. GitHub is a web-based repository platform built on Git, used for code storage and collaboration. **Preparation**: Install Git (download from the official Windows website, use Homebrew or the official website for Mac, verify with `git --version`); register a GitHub account. **Create a Repository**: Log in to GitHub, click "+" → "New repository", fill in the name and description, select Public, check "Add README", and after creation, copy the repository URL (e.g., `https://github.com/username/project.git`). **Local Association**: Navigate to the local project folder, execute `git init` to initialize the repository; `git remote add origin [repository URL]` to associate with the remote. If there is a README, first `git pull origin main` to pull (to avoid conflicts); `git add .` to stage, `git commit -m "notes"` to commit, and `git push origin main` to push to the remote. **Core Commands**: `git init` (initialize), `git add .` (stage), `git commit -m "..."` (commit), `git push origin main` (push). **Common Issues**: Conflicts can be resolved by pulling; if the remote association is incorrect, first use
Read More