Skip to Main Content






Git Basics

Exercise 5: Adding and Pushing to a Remote Repository

  • Objective: Connect a local repository to a remote repository and push changes.

  • Steps:

    1. Create a new repository on GitHub (or any other remote platform).

    2. Add the remote repository URL:

      git remote add origin <REMOTE_URL>

      • Hint: Replace <REMOTE_URL> with the actual URL of your remote repository.
    3. Push the local repository to the remote:

      git push -u origin main

  • Outcome: You will understand how to link a local repository with a remote one and push changes to it.

Exercise 6: Pulling Changes from a Remote Repository

  • Objective: Pull the latest changes from the remote repository to the local repository.

  • Steps:

    1. Pull changes from the remote repository:

      git pull origin main

    • Hint: This command fetches and integrates changes from the remote repository.
  • Outcome: You will learn how to synchronize your local repository with the remote one.

Exercise 7: Fill in the Blanks

  • Objective: Complete the code to push and pull changes from a remote repository.

  • Exercise:

    git remote add ____ <REMOTE_URL>
    git ____ -u origin main
    git ____ origin main

  • Answers:

    • Line 1: origin
    • Line 2: push
    • Line 3: pull