Software is built step by step and piece by piece. Software is often developed as teamwork, and team members need to be able to access the same source code. Several versions of the source code are created during development, and sometimes there is a need to return to an earlier version. It is also important to ensure that once-written source code is not accidentally destroyed or lost.
For this purpose, version control is set up.
In this course (and often in professional software development), a distributed version control system called Git is used. Distributed version control means that local copies of the shared storage location of the source code — that is, the repository — are created on the computers of the users of the version control system. The up-to-date information is often updated from the shared repository to the local repository on one’s own computer when starting work (this is called pull). Changes made to the code are saved as a new version in the local repository (this is called commit) and can be updated back to the shared repository (this is called push).
The operating principles and use of Git were discussed in the previous section. Return to it whenever necessary.
GitHub is a website available to everyone where the source code (repository) of Git projects can be stored and shared. It is also the world’s largest website developed for this purpose, and practically every professional in the software industry uses GitHub in one way or another.
To use GitHub, register as a user at https://github.com/.
Once you have created a user account on GitHub, you can create repositories, or storage locations for projects, there.
There are two ways to connect VSCode and GitHub. VSCode provides a “publish to GitHub” functionality that can be used to connect VSCode to a GitHub account, create a new repository both locally and in GitHub, and push the local repository to GitHub in one go. You can also create a repository in GitHub, create a local repository, and connect the two “manually”. Below are instructions for both ways.
Before you can use Git version control, you need to install the Git software on your computer. Download and install it from https://git-scm.com/downloads according to the instructions.
After installing Git, you can set it up for your Python project:
git config --global user.name "Firstname Lastname".git config --global user.email "email@metropolia.fi". The email address is the same one you used when registering with GitHub..gitignore file in the project root. Add the line .venv/ to the file so that the virtual environment files are not added to version control.Ctrl+Shift+G), and then pressing the Publish to GitHub button.
python-exercises.
After this, the project in the VS Code editor needs to be connected to the GitHub project.
git init.git add ..git commit -m "Initial commit".After this, the local Git repository is ready, and you can connect it to the repository you created on GitHub. There are several different options for doing this.
First, log in to GitHub in the VS Code editor by selecting Sign in to GitHub. Follow the instructions.
Ctrl+Shift+P.GIT: Add Remote in the field and select it.git remote add origin <copied-URL>.git push -u origin main.At this stage, we will look at using GitHub from the perspective of a single developer. In this case, we can assume that different developers do not use the same files, and the problems caused by simultaneous editing do not occur. We also assume that there is no need for us to divide the development project into different development branches. It is worth becoming familiar with the advanced use of GitHub as a collaboration platform for a development team only later, when project work begins.
The VS Code editor has built-in Git support, which is worth using for the basic version control functions. They can be found behind the Git icon in the bar on the left side of the editor (or by pressing the keyboard shortcut Ctrl+Shift+G).

The following practices are worth adopting when working:
You can examine the development branch and its save points on GitHub.
All source code, images, and other valuable files should be stored on GitHub. On the other hand, configuration files and other miscellaneous files related to the runtime environment should be left outside version control. Files containing passwords should also not be stored in version control for security reasons. The files to be excluded are listed in the .gitignore file stored in the project.
For assignments in Oma, always provide a direct link to the solution for the assignments in the relevant module. The easiest way to do this is to navigate to the correct folder in GitHub using a browser and copy the link directly from the browser’s address bar. Name your Python files and folders so that it is immediately clear which assignment solutions they contain.

If your repository is private: For teachers to see your files on GitHub, you need to add the teachers’ usernames as users to your GitHub project. This is done from the Settings tab under Collaborators. The teachers’ usernames are provided through the Oma workspace. Alternatively, you can change your project’s visibility to public in the project settings.

The actual programming begins in the next module.