2

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

1
  • How did you create the first repository? Did you use the 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 using exclude files to make sure not to deploy sensitive things, like credentials. Mar 18, 2019 at 0:13

1 Answer 1

0
  • locate uses databases which may not be updated
  • You need to have your server pull the changes somehow after you push them to the repo.
3
  • 1
    That's what my last conclusion was before I gave up looking for answers on my own. Problem is the following when I try to pull from the remote server I get this error: "fatal: This operation must be run in a work tree" This is when I am in repo.git directory
    – DebianNoob
    Mar 15, 2019 at 11:01
  • If I go back to the main repo directory (outside of the .git directory), I get the following message when I try to pull: "fatal: Not a git repository (or any of the parent directories): .git". Then if I run git init and again git pull, it tells me this: "No remote repository specified. Please, specify either a URL or a remote name from which new revisions should be fetched."
    – DebianNoob
    Mar 15, 2019 at 11:09
  • Seems like you have lots of pointers to be researching to me.
    – sdasd
    Mar 15, 2019 at 11:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .