3

I have created a repo within cPanel, cloned it to my local computer and then added some files. Now when i push the commits back up, everything seems to work nicely. However, the cPanel filemanager shows no files in the corresponding repo except for the .git-Folder.

This is what I do in git bash:

This is what I do in git bash

This is what the cPanel filemanager shows me... nothing:

This is what the cPanel filemanager shows me... nothing

Any clues?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
glades
  • 3,778
  • 1
  • 12
  • 34

2 Answers2

1

Git would checkout files with content.

You have created three empty files (touch a.txt)

Try again, with a minimal content

echo "test">a.txt
git add .
git commit -m "a with content"
git push 

Another explanation: the remote repository is a bare one (its .git/config file includes bare = true)

Or, following git config receive.denyCurrentBranch on the server (cPanel) side: since it is set to ignore... it will allow the push but will not update the working tree.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 2
    Thanks, but it's still the same. No files up there. I have a .cpanel.yml file besides those text files which also has content, but it's not being pushed either :/ – glades Jul 12 '19 at 10:32
  • 2
    @glades If you clone that remote URL in a new local folder, do you get any file? – VonC Jul 12 '19 at 10:47
  • 1
    Yes I do! It appears to me that the files are saved, but only as commits and not as real hands-on files. I found a tutorial here: https://www.youtube.com/watch?v=fXHPPNaDD-8. When I fallow his steps exactly, I still don't get the same results (files still missing). However, I have to say that I had to manipulate the server git config file along the way, as `receive.denycurrentbranch` was set to `updateInstead`. I changed it to `ignore`. But that shouldn't be the problem right? – glades Jul 12 '19 at 10:55
  • 2
    @glades Can you check on the server if the `.git/config` on your server side includes "`bare = true`"? – VonC Jul 12 '19 at 11:23
  • 1
    No, bare is set to false. In fact, the config file looks like this: `[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [receive] denycurrentbranch = ignore [gc] auto = 0` – glades Jul 12 '19 at 11:32
  • I just noticed, that if I clone a repo from github and don't use a new repo then the files appear. However, then the server is acting as a client and I suppose that is not the same.. – glades Jul 12 '19 at 11:46
  • 1
    @glades From your new clone (not from Github but from your server), can you try and add new content, to see if it shows up when pushing back up? – VonC Jul 12 '19 at 11:49
  • Yes I just tried it. I created some text files on the server repo via ssh and pushed it to github. They appeared as they should. – glades Jul 12 '19 at 12:02
  • 1
    @glades I meant: if you clone your cPanel repo (not GitHub) locally in a new folder, add new files (with content) commit and push back, nothing popup on the CPanel side? – VonC Jul 12 '19 at 12:44
  • No unfortunately, i tried that several times :/ When I do the same with a github repo, it works however. – glades Jul 12 '19 at 12:47
  • 1
    @glades Yes, that is why I asked if, on the Cpanel remote server side (the one you see through a web page), the `.git/config` included `bare = true`, because that would explain why no files are showing up. – VonC Jul 12 '19 at 12:56
  • That would indeed explain it, but it's set to false :/ I've now tried pushing to github via SSH to make sure that is not the problem. It works fine. All changes are applied to the online repo. I just don't get it.. – glades Jul 12 '19 at 13:36
  • 1
    I see: https://git-scm.com/docs/git-config#Documentation/git-config.txt-receivedenyCurrentBranch. If set to ignore, it allows the push but does nothing else. Only `updateInstead` would show you the files pushed. – VonC Jul 12 '19 at 13:50
  • 1
    AHA! now it all makes sense. You know, updateInstead was actually set as a configuration in the beginning, but I had to set it to ignore, because the git version on my server is 2.19.1, and updateInstead is only supported from 2.4 onwards i think. Anyway, i got an error that didn't allow me to push. Which leaves the question, why my hoster installed that old git version and still set attributes that don't make sense. I'm confused. Compare: https://stackoverflow.com/questions/56990207/fatal-bad-config-value-for-receive-denycurrentbranch-in-config – glades Jul 15 '19 at 13:46
1

This will solve your problem for sure as i wasted my 5 hour in search for the same issue -

  1. First check the GIT VERSION on remote using ssh using command git --version In my case it was 2.19.1 which is this root cause for this problem.
  2. I suggest to create a new repo on cPanel before staring the below process, once you create new repo check following....
  3. Now make sure on remote config denyCurrentBranch = updateInstead below is my remote config screenshot, you can check remote config using command git config --edit when you inside remote repo directory My Live git config screenshot

  4. Now clone the cpanel repo on your local, and check your local git config file and make sure it has the tag [remote "origin"] [Screenshot 2 ]if you can't find it use this command on your local git remote add origin ssh://username@website/home/username/reponame

  5. Now simply add any test file and commit the changes and push using below command and your remote repo will get updated 100% git push origin master -u --exec=/usr/local/cpanel/3rdparty/bin/git-receive-pack

Best Of Luck :)