Using git in VSCode
This is a short guide on how to use git in Visual Studio Code (VSCode). The purpose of git is to allow you to easily share your code with collaborators and track the changes each of you make.
Note: We assume you have already signed up for GitHub and installed git on your computer. Otherwise, see step 3 in this guide.
Cloning a repostiory
Ctrl+Shift+P + run git: clone
+ write link to repository (from e.g. step 1)
Working with a repostiory
Open folder with repository (e.g. the one you just cloned in step 2)
Download existing changes: Ctrl+Shift+P + run
git: sync
Make some changes, add/remove files, etc. (it does not matter whether it is done in VSCode, JypterLab or from your OS)
Upload new changes:
Ctrl+Shift+P + run
git: commit all
(choose "Always" if there is a pop-up)Write commit message
Ctrl+Shift+P + run
git: sync
(choose "OK, don't show again" if there is a pop-up)
IMPORTANT NOTE: To avoid merge conflicts always download existing changes, before you make new ones. This reduces the risk of merge conflicts, where you and your collaborators have changed the same lines of code
4. Video guides for working with Git
Victor and Christian create a repository and push their project to it here.
A short explanation of important concepts and commands in Git, also found in L05, can be seen here.
In this video, you'll see some examples of how to make additional commits across members to the project that Victor and Christian had uploaded. Also, solving merge conflicts.
5. Merge conflicts
Skip this if you are a first time user of git
If you get a merge conflict:
Resolve conflicts by point-and-click (don't save the file)
Ctrl+Shift+P + run
git: stage all changes
Ctrl+Shift+P + run
git: commit all
Ctrl+Shift+P + run
git: sync
Save the file
Ctrl+Shift+P + run
git: commit all
Ctrl+Shift+P + run
git: sync
Problems? You can undo last commit with git: undo last commit
Worst case: Make a new clone of the repository and redo the changes file-by-file.