GitHub stores a copy of your project along with the full history of every change, and Git is the program on your computer that records those changes and sends them. If you built your project with Cursor, Claude Code or ChatGPT, putting it on GitHub is the easiest way to get it onto hosting later, because the server pulls the code from the repository instead of you copying files by hand each time.
Before you start
- A GitHub account (free).
- VS Code or Cursor (Cursor is built on VS Code, so the menus are nearly the same).
- Your project folder on your computer.
Steps
1. Install Git
- Windows: download the installer from git-scm.com and accept the defaults. It includes Git Credential Manager, which handles signing in to GitHub.
- macOS: open Terminal and type
git --version. If Git isn’t installed, macOS offers to install the Command Line Tools. - Linux: use your package manager, for example
sudo apt install git.
Then tell Git your name and email once; they appear on every commit:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Restart VS Code after installing so it finds Git.
2. Create a .gitignore first
This file lists what Git must never upload. Create it in the project root, named .gitignore (with the leading dot). A starting point for most Node.js, Laravel and Python projects:
# secrets
.env
.env.*
!.env.example
# dependencies (rebuilt on the server)
node_modules/
vendor/
venv/
__pycache__/
# build output and logs
dist/
build/
.next/
*.log
.DS_Store
Why: .env holds your database password and API keys, and folders like node_modules and vendor are large and rebuilt with one command. Keep a .env.example with the variable names and no values, so whoever gets the project knows what it needs. More in setting .env variables on hosting.
A note for Laravel on hosting without SSH: the server needs vendor. The safer route is to keep it out of Git and upload it in a ZIP, as in deploy Laravel on cPanel without SSH.
3. The easy way: Publish to GitHub from VS Code
- Open the folder with File then Open Folder.
- Open the Source Control panel from the sidebar (the branch icon) or with
Ctrl+Shift+G. - If the folder isn’t a repository yet, you’ll see Initialize Repository and Publish to GitHub. Click Publish to GitHub.
- VS Code asks you to sign in to GitHub in the browser. Allow it.
- Choose Publish to GitHub private repository or public repository.
- A list of files to include appears. Check that
.envandnode_modulesare not in it, then confirm.
VS Code creates the repository on GitHub and pushes the first commit, then shows an Open on GitHub button.
4. Later changes: Commit, then Sync
After you edit files, they appear in Source Control under Changes:
- Type a short message describing the change in the Message box, such as
fix contact form. - Click Commit. If it asks whether to stage all changes, choose Yes, or click + next to only the files you want.
- Click Sync Changes to send the commit to GitHub.
5. The same thing from the terminal
If you prefer the command line, or want to see what VS Code does: first create the repository on GitHub with New repository, give it a name, choose Private, and don’t add a README or .gitignore there so the two sides don’t diverge. Then, inside the project folder:
git init
git add .
git status # check that .env and node_modules are NOT listed
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/USERNAME/my-project.git
git push -u origin main
After that, each change is just:
git add .
git commit -m "describe the change"
git push
6. If you committed .env by mistake
git rm --cached .env
echo ".env" >> .gitignore
git commit -m "stop tracking .env"
git push
This stops tracking the file, but the old copy is still in the history. Change the database password and every API key it held, and revoke the old keys in each provider’s dashboard.
How hosting pulls the project from GitHub
Once the project is on GitHub, the server can get it in one of these ways:
| Method | Repository | Needs SSH |
|---|---|---|
cPanel Git Version Control with a .cpanel.yml file |
Public, over HTTPS | No |
| Git Version Control with a deploy key | Private | Yes, to create the key on the server |
| GitHub Actions uploading over SSH | Public or private | Yes |
| Download a ZIP from GitHub (Code then Download ZIP) and upload it | Any | No |
In cPanel, open Git Version Control, click Create, paste the repository link into Clone URL and pick a path outside public_html. After each push, click Update from Remote and then Deploy HEAD Commit on the Pull or Deploy tab. The full walkthrough with .cpanel.yml examples is in Git deployment in cPanel and auto deploy from GitHub.
Troubleshooting
src refspec main does not match any: there’s no commit yet. Rungit add .andgit commitfirst.Updates were rejected because the remote contains work: you created a README on GitHub. Rungit pull --rebase origin main, thengit push, and see git push rejected.Authentication failedor a password that never works: sign in through the browser, or use a personal access token or an SSH key.node_modulesended up in the repository: it was added before.gitignore. Rungit rm -r --cached node_modulesand commit.LF will be replaced by CRLFon Windows: a warning, not an error; it doesn’t block the push.
On ArabyHost
Every ArabyHost website plan can pull from GitHub with cPanel’s Git Version Control and a .cpanel.yml file, through the Git tab in the Araby Panel for a public HTTPS repository, or by ZIP upload. Private repositories and GitHub Actions over SSH need the AI/Developer plans, which include SSH jailed in CageFS with Git, Composer, Node.js and Python, and you can also deploy from Claude or Cursor through Araby MCP. No plan has root access. The panel steps are in deploy from GitHub, and current prices in your currency are on the pricing page.
FAQ
Should my repository be public or private?
Private is the safer default for most business projects: only you can see it. Public repositories are visible to anyone but are easier to pull onto hosting without SSH. Either way, never put passwords or API keys in it.
I pushed my .env file by mistake. What now?
Run `git rm --cached .env`, add `.env` to `.gitignore`, then commit and push. The file is still in the repository history, so change every password and key it contained right away; that matters more than deleting it.
Why does GitHub reject my password on git push?
GitHub doesn't accept your account password for Git over HTTPS. Sign in through the browser window VS Code or Git Credential Manager opens, or use a personal access token or an SSH key.
Does my hosting deploy automatically when I push to GitHub?
Not in the simple setup. You connect the repository once in cPanel's Git Version Control, then click Update from Remote and Deploy HEAD Commit after each push. Deploying on every push needs GitHub Actions and SSH access.