Skip to content

Untitled

Git workflow: Remote

๐Ÿ‘€ Overview

In this module, you will learn how to work with a remote repository using GitHub and GitLab (look at the tutorial).

You will clone a remote repository, update your local repository and push changes to the remote.

Additionally, you will learn how to create a Merge Request to propose changes to the original repository.

๐ŸŽฏ Goals

  • Clone an existing repository from the remote.
  • Update the local repository with changes made on the remote repo.
  • Push changes from the local repository to the remote.
  • Create a Merge Request to propose changes to the original repository.

โš’๏ธ Tutorial: Work with the remote repository (GitLab)

1. Create and clone a repository

To clone a repository means to download the files from the remote repository to your computer and to create a connection between them.

To clone a repository:

  1. Open a terminal and go to the directory where you want to clone the files
  2. Copy the Git SSH URL of the repository (REPO_URL)

    Merging
    Copy the Git URL

  3. Clone the repository using the command git clone in the CLI.

git clone REPO_URL

Note

Git automatically creates a folder with the repository name and downloads the files there.

2. Create and Update dev branch, push it to the remote

Now letโ€™s see how to work with a remote repository using GitHub.

  1. First, we navigate to our 3-git-remote directory using the command cd 3-git-remote.

# Go to the repository 
cd 3-git-remote
2. Then, we need to create a new branch called dev. In this way, you can make changes without affecting the main codebase. And we immediately switch to a new branch with the command git checkout -b dev.

# Create `dev` branch and checkout to it (-b flag)
git checkout -b dev
3. Next, we create a new file called config.yaml using the touch command and add a line to it using echo "repo: project-1-git" >> config.yaml. We confirm the changes using cat config.yaml. This command will print the fileโ€™s content.

# Create a config file, make changes, confirm them
touch config.yaml 
echo "repo: project-1-git" >> config.yaml
cat config.yaml
4. Also, we add and commit the changes to the local repository using

# Add and commit changes
git add config.yaml && git commit -m "Add config.yaml"
5. Finally, we push our changes to the remote repository (named origin) in the โ€˜devโ€™ branch using the git push origin dev command.

# Push changes to the remote repository
git push origin dev

3. Create a Merge Request: dev โ†’ main

Create a Merge Request via GitHub or GitLab UI to theย mainย branch

๐Ÿ Conclusion

Congratulations on completing this tutorial! ๐Ÿฅณ

You have learned how to work with a remote repository. You set up SSH to connect to GitHub / GitLab, cloned a remote repository, updated your local repository, and pushed changes to the remote.

Furthermore, you learned how to create a Merge Request to propose changes to the original repository.

๐ŸŽ“ Additional Resources:

ย Contribute to the community! ๐Ÿ™๐Ÿป

Hey! We hope you enjoyed the tutorial and learned a lot of useful techniques ๐Ÿ”ฅ

Please ๐Ÿ™๐Ÿปย take a moment to improve our tutorials and create better learning experiences for the whole community. You could

  • โญย Put a star on our ML REPA library repository on GitHub
  • ๐Ÿ“ฃย Share our tutorials with others, and
  • Fill out the Feedback Form We would appreciate any suggestions or comments you may have

Thank you for taking the time to help the community! ๐Ÿ‘

Untitled