Module 4 of 13 · Getting Started with AI Development · Beginner

Git Remotes: GitHub and GitLab

Duration: 5 min

What is a Remote Repository?

A remote repository is a copy of your project stored on a server like GitHub or GitLab. It allows you to backup your code, collaborate with others, and access your project from anywhere.

GitHub vs GitLab

GitHub (github.com) and GitLab (gitlab.com) are popular platforms for hosting Git repositories. GitHub is owned by Microsoft and is the most popular. GitLab is open-source and offers more features for free. Both work the same way with Git commands.

Creating a Remote Repository

  1. Go to github.com or gitlab.com and create an account
  2. Click 'New Repository' or 'New Project'
  3. Name it 'my-ai-project'
  4. Do NOT initialize with README (we already have commits)
  5. Copy the repository URL

Connecting Local to Remote

# Add the remote repository (replace URL with your actual URL)
git remote add origin https://github.com/yourusername/my-ai-project.git

# Verify the remote is added
git remote -v

# Push your commits to GitHub
git branch -M main
git push -u origin main

Try it in Google Colab: Open in Colab

origin  https://github.com/yourusername/my-ai-project.git (fetch)
origin  https://github.com/yourusername/my-ai-project.git (push)
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 236 bytes | 236.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/yourusername/my-ai-project.git
 * [new branch]      main -> main

Understanding Branches

A branch is a separate line of development. 'main' (or 'master' in older repos) is the default branch. You can create new branches to work on features without affecting the main code.

# See all branches
git branch

# Create a new branch
git branch feature/add-model

# Switch to the new branch
git checkout feature/add-model

# Or create and switch in one command
git checkout -b feature/add-model
* main
  feature/add-model

💡 Tip: Use descriptive branch names like 'feature/user-auth' or 'bugfix/login-error'. Avoid names like 'test' or 'temp'.

Learn Advanced Git

Ready for more? Explore advanced Git topics:

❓ What does 'origin' refer to in Git?

← Previous Continue interactively → Next →

Related Courses