How to version your project?¶
When working on a project, it is important to version your work. Even on your own!
The reasons are simple:
- Go back if you make a mistake or a botched implementation
- Have several versions: testing, stable…
- Manage issues (tasks)
That said, versioning your project is not mandatory. It is a plus for you (a professional skill).
Prerequisites¶
You must already have:
- an account with your GIT provider
- GIT installed on your machine
To version the project:¶
1/ Create a new empty repository with your GIT provider (Github, GitLab ...)
Important information
Please note that the repository must be EMPTY when it is created. Otherwise, you will have trouble pushing your files.
2/ Open a terminal and go to the root of the project
3/ Type the following lines:
- Initialize the project
- Add the URL of the GIT repository (HTTPS or SSH)
Important information
Replace URL_GIT_REPO with the URL of the repository you created
Copy the URL shown in the repository's GIT service
Here is an example:
This is only an example and it will probably not be yours. Here we selected the SSH protocol to link to the repository. You can also use the HTTPS protocol. SSH is more secure and faster than HTTPS. However, it requires extra configuration on the machine, including installing an SSH key. Example of SSH configuration: Github SSH
- Add the "main" branch
- Add the files to the commit
- Add the 'init project' commit
- Push the local files to the remote repository
Push errors¶
If you get errors when pushing, here are a few commands to help you:
Show the URLs of the GIT repositories configured in your project:
To remove the origin URL already configured in your GIT: