Do the following.
Suppose your project, on the server, is in the /var/www/projeto
folder. Clone your repository to another folder, for example, /var/www/projeto_git
:
git clone <repositório> <pasta de destino>
The branch that will be cloned will default to master
. Create another branch named, for example, servidor
:
git checkout -b servidor
Then, copy all files from the folder of your project to your repository:
cp -R /var/www/projeto /var/www/projeto_git
This is done by committing the files with a very clear message (for example, "server files") and sending them to the remote server:
git add --all
git commit -m <mensagem de commit>
git push -u origin servidor
In this way you will have two branches in your repository: master
, which contains the original project, and servidor
, which has your project modified with the files on the server where is hosted.
(Just a little detail: since you have little Git experience, be careful about versioning files with sensitive information in a public repository, prefer private repositories.)
Finally, if you want to download the modified project in your development environment, run the following command:
git checkout -b servidor origin/servidor
In this way, you can compare the two branches (that is, which files exist in one branch and not the other) and the differences between files with the command:
git diff master..servidor