Git is a version control system that records changes to a file or set of files over time and allows you to revert to a specific version later. To get started, you need to know that Git does not store files, it configures file nuggets.
The first thing you should do after installing Git is provide your name and email address. This is important because every commit in Git contains this information, and it is included in the commits you commit and cannot be changed further:
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
We create a local repository on the hosting.
After creation, we need to connect our Git to the repository on the hosting.
We clone the repository created locally on the hosting.
git clone (link to the repository created on the hosting)
Git works over both http and https protocols
Example:
git clone https://billur@example.ru/plesk-git/example.git
after this, authentication is required.
Enter the password for the FTP user you also created on the hosting (authorization is only available for the system user)
If you are going to start using Git for an existing project, then you need to go to the project directory and enter:
$git init
If you want to add version control to existing files (as opposed to an empty directory), you should add them to the index and make the first commit of the changes.
You can achieve this by running the git add command several times, specifying the files to index, and then running git commit:
$git add *.c
$ git add LICENSE
$ git commit -m 'initial project version'
It is also possible to use a remote repository (for example, GitHub or BitBucket)
We would like to note that virtual hosting plans only allow connections to public repositories. There is no access to private repositories; if you need to use private repositories, we advise you to use the "Virtual Server" service
the connection occurs in the same way as a local one, only a link to a third-party repository is indicated.
We would also like to note that when using a remote repository, you can receive changes made by clicking the “get updates” button in your subscription in the Plesk hosting control panel
Once there is a connection to the repository, all that remains is to add our project files
You need to enter the local directory of your project
cd (path to final directory)
index files with the command
$git add *.*
Adding a commit
$git commit
Checking the status
$git status
Submit to the repository
$git push
It is also possible to delete a local branch
$ git branch –d {the_local_branch} (use –D instead of forcing the branch to be deleted without checking the merged state)
To remove a remote branch from the server
$ git push origin –delete {the_remote_branch}
to update data that was entered by other users, use the command
$git pull
We also want to note that if the files were not uploaded through the Git client, then when you try to pull them through Git, the Git client will not see them.