Command | Description |
---|---|
git remote |
Manages remote repositories |
git clone |
Creates a local copy of a repository |
git pull |
Fetches and merges the latest changes from a remote repository into the current branch |
git fetch |
Updates remote tracking branches |
git push |
Uploads local commits to a remote repository |
This session
In this session, you will work on the following tasks:
- Reading: Read the chapter “Remotes - Introduction” in the Version Control Book.
- Implementation: Try out the commands in the chapter.
- Exercises: Work on the exercises for the
recipes
project. - Quiz: Test your knowledge with the quiz.
As always:
- Try out the commands of this session and play around with them.
- Check whether you have achieved the learning objectives.
- Ask questions!
- Let’s git started!
Learning objectives
💡 You can create a remote repository.
💡 You can connect your local Git to a remote repository service.
💡 You can pull and push changes to and from a remote repository.
💡 You can clone a repository from a remote repository service.
recipes
project
At the end of this session, you should have accomplished the following:
- You connected your GitHub account to your local Git.
- You created a new GitHub repository and uploaded (i.e., “pushed”) your
recipes
project. - You collaborated on a shared project by adding and committing changes to a partner’s repository.
Optional:
- You cleaned up your project by deleting unnecessary files and branches.
- You created a short
README.md
file in your repository.
Please keep the recipes
folder! We will continue to use it in the following sessions.
Exercises
Connect to remote repositories using SSH
- Generate an SSH key.
- Copy the SSH key to your clipboard.
- Add the SSH key to the remote repository (for example, GitHub or GitLab).
Upload your local repository to a remote repository
- Create an empty repository on the remote repository hosting platform, for example GitHub or GitLab. Make sure to not initialize the repository with any files!
- If needed, navigate to the
recipes
repository using the command line. - Set the remote URL of your local repository to your remote repository.
- Push the changes on your
main
branch to your remote repository.
“Private” collaboration with pull requests (using GitHub Flow)
- Add your exercise partner as a collaborator to your
recipes
repository. - Clone your partner’s repository.
- Create a new branch in your collaborator’s repository.
- Add a recipe to your collaborator’s
recipes.txt
file. - Add and commit the changes.
- Push the changes on the new branch to the remote repository.
- Create a Pull / Merge Request.
- Review the PR your collaborator made in your repository.
- 🚀 Optional: Add additional changes on the branch pushed by your collaborator.
- Merge the PR into your repository.
🚀 Bonus exercises
Add a README.md
- Find the option to create a new file on your remote repository in the browser.
- Name the file
README.md
, add a brief description, and provide a commit message. - 🚀 Optional: Play around with Markdown syntax.
- Save the
README.md
file to the repository. - Pull the changes to your local repository.
Clone and sync your repository
- Move to a location on your computer where you want to clone a repository.
- Clone your remote repository to a different location on your computer.
- Stage and commit changes in the new location (consider using a new branch).
- Push these new changes to GitHub.
- Pull the changes to the repository in the original location.
- Delete your newly cloned repository.
Slides
To export the slides to PDF, do the following:
- Toggle into Print View using the E key (or using the Navigation Menu).
- Open the in-browser print dialog (CTRL/CMD+P).
- Change the Destination setting to Save as PDF.
- Change the Layout to Landscape.
- Change the Margins to None.
- Enable the Background graphics option.
- Click Save.
Note: This feature has been confirmed to work in Google Chrome, Chromium as well as in Firefox.
Here’s what the Chrome print dialog would look like with these settings enabled:
These instructions were copied from the Quarto documentation (MIT License) and slightly modified.