I am hosting a git server on my Debian Stretch server in the /var/www/example.com/html directory.
I am able to push files to this server on my local computer if I first clone the git repo by doing this on my windows 10 local computer:
C:\Users\User\Desktop\AnotherRepoTest\test>git clone git@IP_Of_Remote_server:/var/www/example.com/html/repo.git
Cloning into 'repo'...
git@IP_Of_Remote_server's password:
remote: Counting objects: 20, done.
Receiving objects: 100% (20/20), 2.30 KiB | 1.15 MiB/s, done.
remote: Compressing objects: 75% (9/12) Resolving deltas: 100% (4/4), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 20 (delta 4), reused 0 (delta 0)
C:\Users\User\Desktop\AnotherRepoTest\test>
This works and it gets the files from the repo, but if I make a new file and then push this file to the master branch, the remote server will not show this new file in the remote repo directory.
C:\Users\User\Desktop\AnotherRepoTest\test>cd repo
C:\Users\User\Desktop\AnotherRepoTest\test\repo>echo "Hello, world." > AddThisFile.txt
C:\Users\User\Desktop\AnotherRepoTest\test\repo>git add --all
C:\Users\User\Desktop\AnotherRepoTest\test\repo>git commit -m "New Commit"
[master e5a21b6] New Commit
1 file changed, 1 insertion(+)
create mode 100644 AddThisFile.txt
C:\Users\User\Desktop\AnotherRepoTest\test\repo>git push -u origin master
git@IP_Of_Remote_server's password:
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 292 bytes | 292.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To IP_Of_Remote_server:/var/www/example.com/html/repo.git
78da987..e5a21b6 master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
C:\Users\User\Desktop\AnotherRepoTest\test\repo>
As you can see, everything went as expected. Now if we check the remote server repo directory this new text file is not added inside the /var/www/example.com/html/
But if I clone the repo again in a different folder on my local machine, this text file will be cloned.
So the problem is that I cannot locate this file on the remote directory. Even when I run:
root@ohwell:/var/www# locate AddThisFile.txt
root@ohwell:/var/www#
I have given the git user only git-shell access and has correct permissions on the /var/www directory. I have even rebooted the server to see if changes come in, but no luck. How come I am unable to locate this file on the remote server? What am I missing?
I have setup a bare repo following these tutorials:
https://www.linux.com/learn/how-run-your-own-git-server
https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server
bare
option or not? Also, as the directory name implies, it may not be a good idea to store the git repository under a publicly available URL. Using git for website deployment usually means having a git repository "somewhere" (on website host or elsewhere this does not matter, but not publicly accessible through the webserver), and then deploying by checking out a specific branch or tag into the website hierarchy, taking care of usingexclude
files to make sure not to deploy sensitive things, like credentials.