[GIT] Adding your project to Git repo
After creating your project locally, add them to Git repo.
Note: A pre-requisite GitHub account is required. If you havenβt set up Git identity or SSH keys yet, check out Setting Up Git (and MCP?) on a New Laptop first.
1. Initialize Git in Your Project
Navigate to your project folder and turn it into a Git repository:
Initialize a new Git repo
git init
2. Stage and Commit Your Files
Check what will be added
git status
Stage all files
git add .
Create your first commit
git commit -m "Initial commit"
3. Create a Repository on GitHub
Go to github.com/new and create a new, empty repository. Donβt initialize it with a README, .gitignore, or license if youβre pushing an existing local project β that avoids conflicting histories.
4. Link Your Local Repo to GitHub
GitHub will show you a remote URL after creating the repo. Use the SSH version if youβve already set up an SSH key, or HTTPS otherwise.
Add the GitHub repo as a remote (SSH)
git remote add origin git@github.com:username/repo-name.git
Add the GitHub repo as a remote (HTTPS)
git remote add origin https://github.com/username/repo-name.git
Verify the remote was added
git remote -v
5. Push Your Code
Rename your branch to main (if needed)
git branch -M main
Push and set upstream tracking
git push -u origin main
6. Verify
Refresh the repo page on GitHub β your files should now be there. Future pushes only need:
Push subsequent commits
git push
Thatβs it β your local project is now backed by a GitHub repo, and every commit you make can be pushed up with a single command.