Codetainer LogoCodetainer Acad

Lessons

Lesson 14: Pushing to GitHub

🚀 Lesson 14: Pushing to GitHub

GitHub is a cloud-based platform that lets you host and manage your Git repositories online. It's like Dropbox for your code — but with version control, collaboration, and pull requests.

1. Create a Repository on GitHub

Go to github.com and create a new repository. You can give it a name, description, and choose whether it should be public or private.

2. Copy the Repo URL

Click the green "Code" button and copy the HTTPS URL of your new repo. It looks like: https://github.com/your-username/your-repo.git

3. Link Your Local Repo and Push

In your local terminal, run:


git remote add origin https://github.com/your-username/your-repo.git
git branch -M main
git push -u origin main

Here’s what each command does:

  • git remote add origin: Links your local project to the GitHub repo
  • git branch -M main: Renames your current branch to main (standard convention)
  • git push -u origin main: Pushes your code to GitHub and sets the upstream branch

🔍 You’re Live!

Head over to your GitHub repository URL. Boom 💥 — your code is live and version-controlled on the cloud.

🧠 Pro Tips

  • Create a .gitignore file to avoid pushing unnecessary files
  • Add a README.md so people know what your repo is about
  • Use SSH instead of HTTPS for easier and more secure push/pull (optional)
CodetainerAcad