git push always says "Everything up-to-date" but nothing is pushed

Operating System & Version
macOS 12.3.1
cPanel & WHM Version
cPanel 94.0.24

Fabius

Member
May 11, 2022
9
3
3
UK
cPanel Access Level
Website Owner
I'm trying to push my local git repository to my cPanel server but it always says "Everything up-to-date", despite no/few files being listed as copied, and nothing appearing on the server.

  • I've set up an empty Git Repository in cPanel, with a path like /home/username/git_repositories/my-repo-name (obviously, with the correct username and repo name)
  • I've checked that the ~/git-repositories/my-repo-name directory is there on the server.
  • I've set up SSH Access and can ssh to the server from my local computer.
  • I have an existing git repository on my computer. It's origin is a private GitHub repository, but I'm just trying to push from my computer to the cPanel server, not connect to the GitHub repository from cPanel
I've added a .cpanel.yml file to the root of my repository that currently looks like this:

Code:
---
deployment:
  tasks:
    - export DEPLOYPATH=/home/username/test/
I've done this on my computer (having copied the correct "ssh://..." path from cPanel instructions):

Code:
git remote add cpanel ssh://[email protected]/home/username/git_repositories/my-repo-name
git push cpanel main
But nothing appears in my /home/username/git_repositories/my-repo-name directory - shouldn't all the code appear there?

If I change a file, commit it, and push again then it says it pushes:

Code:
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 436 bytes | 436.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0), pack-reused 0
To ssh://[email protected]/home/username/git_repositories/my-repo-name
   8068ad7..d265b59  main -> main
But, still nothing appears on the server. What am I missing?
 

Fabius

Member
May 11, 2022
9
3
3
UK
cPanel Access Level
Website Owner
I've just now noticed that in cPanel, if I go to "Manage" the repository, there's a "Checked-Out Branch" field. If I select the "main" branch and click "Update" then my files all appear!

I don't see any mention of needing to do that in the cPanel documentation about Git.
 

Fabius

Member
May 11, 2022
9
3
3
UK
cPanel Access Level
Website Owner
I don't know to be honest. The Git documentation is several pages and I was having to jump back and forth between them, and various third-party blog posts, to try and figure out how to get anything working.

The "Checked-out Branch" bit is mentioned at the very end of Git™ Version Control | cPanel & WHM Documentation But then other pages like Guide to Git™ - Host Git Repositories on a cPanel Account | cPanel & WHM Documentation mention the Git Version Control page but then go on to only use the command line.

I was really lacking a simple step-by-step process for setting things up using cPanel, instead of the command line.