Basics of Git Version Control - vonkarmaninstitute/pantera-pic-dsmc GitHub Wiki
What is Git?
Git is a version-control system for tracking changes in computer files and coordinating work on those files among multiple people. Git is a Distributed Version Control System. So Git does not necessarily rely on a central server to store all the versions of a project’s files. Instead, every user “clones” a copy of a repository (a collection of files) and has the full history of the project on their own hard drive. This clone has all of the metadata of the original while the original itself is stored on a self-hosted server or a third party hosting service like GitHub or GitLab. Pantera is hosted on sbocce's GitLab repository.
Basic Git Commands
First, you will mostly work on your individual branch of Pantera, an independent version of the software that at some point in time was "branched" from another branch, such as the "master" branch. On Linux, you should have git already installed, otherwise you can install it (on Ubuntu) with
sudo apt-get install git-all
Once installed, the first thing you will do is clone the branch you will work on to your local machine. This is done with the command
git clone --branch [name of your branch] [url of the repository]
Where [name of your branch]
will be something like pantera-pippo
, and [url of the repository]
can be found by clicking on the "clone" button on the website of the repository (e.g. GitLab).
Once you make changes to the code and maybe even add new source files, you can synchronize the changes with the online copy of your branch. To do this, you have to follow these three steps:
- Add existing/new files to be synchronized. This can be done with
git add [file name]
To add a single file, and
git add -u
To add all previously included files that have changed since your last synchronization.
- Commit the changes to the repository, including a message describing the latest changes you've made, with the command:
git commit -m "[your commit message]"
- And, finally, push the changes to the remote repository:
git push origin [name of your branch]
Where, again [name of your branch]
will be something like pantera-pippo
.
That's it! Git is a very advanced system, so online you can find many resources explaining how to fully exploit it.