Git Deployment

Managing a Sample App with Git, GitHub, and VSCode: Cloning, Editing, and Deploying

By the Domain India teamPublished 8 min read
Knowledge base article
Contents (9 sections)

Git records every change to your code, GitHub keeps a shared copy online, and Visual Studio Code (VS Code) gives you buttons for both. Together they make a simple, reliable workflow: edit on your computer, push to GitHub, and pull the new version onto your server. This guide walks through that loop with a sample app, from the first commit to deploying on your own VPS.

Key takeaways

Initialise a Git repository in your app folder, commit, and publish it to GitHub (VS Code's Publish to GitHub button does this in one step). Edit and commit in VS Code, then push. On your VPS, clone the repository once with a read-only deploy key, and for each release run git pull and restart the app. When releases become frequent, automate the pull with GitHub Actions.

1. What you need

  • Git on your computer. On Windows, install Git for Windows; on macOS, run git --version and accept the prompt to install the developer tools; on Linux, use your package manager.
  • VS Code, which has Git support built in.
  • A GitHub account. GitHub no longer accepts your account password for Git operations, so you sign in through VS Code (a browser login) or use an SSH key.
  • A server to deploy to. This guide uses a Linux VPS where you have root or sudo access. For shared hosting, see section 7.

2. Create the repository and make the first commit

Open a terminal in your app's root folder (in VS Code: Terminal → New Terminal) and run:

bash
git init -b main
git config user.name "Your Name"
git config user.email "[email protected]"

Before you commit anything, create a .gitignore file so that dependencies, build output and secrets stay out of the repository:

text
node_modules/
vendor/
dist/
.env
*.log

Then commit:

bash
git add .
git commit -m "Initial commit"
Never commit secrets

Passwords, API keys and database credentials belong in a .env file that is listed in .gitignore, not in your code. If a secret has already been pushed to GitHub, removing the file is not enough: change the password or key, because it stays in the repository history.

3. Publish the repository to GitHub

The easiest route is VS Code: open the Source Control view and click Publish Branch (or Publish to GitHub). VS Code asks you to sign in to GitHub in your browser, lets you choose a private or public repository, and pushes your code.

To do it from the terminal instead, create an empty repository on GitHub (no README, so there is nothing to merge), then:

bash
git remote add origin [email protected]:your-user/sample-app.git
git push -u origin main

That URL uses SSH, which needs an SSH key added to your GitHub account. The HTTPS URL (https://github.com/your-user/sample-app.git) works too; Git's credential manager opens a browser login the first time.

4. Clone the repository on another computer

To work on the same app from another machine, or to start from a repository someone else created:

  1. Open the Command Palette.
    Press Ctrl+Shift+P (Cmd+Shift+P on macOS).
  2. Run "Git: Clone".
    Paste the repository URL, or choose Clone from GitHub to pick from your repositories.
  3. Choose a folder.
    VS Code downloads the repository and offers to open it.

5. The daily loop: branch, edit, commit, push

Work on a branch, so that main always holds a version you could deploy:

  1. Create a branch.
    Click the branch name in the bottom-left corner of VS Code and choose Create new branch, for example fix-contact-form.
  2. Edit and save.
    Changed files appear in the Source Control view, and clicking one shows a side-by-side diff.
  3. Stage and commit.
    Click + next to each file (or next to Changes for all), type a short message that says what changed, and click Commit.
  4. Push.
    Click Sync Changes or Publish Branch to send the branch to GitHub.
  5. Open a pull request.
    On GitHub, open a pull request from your branch into main. Review the diff, merge it, and delete the branch.
  6. Update your local main.
    Switch back to main and pull, so you start the next change from the latest code.

Small, frequent commits with clear messages make it easy to see what broke and to undo it with git revert.

6. Deploy to your VPS

The first time, give the server read-only access to the repository with a deploy key. It is safer than putting your personal GitHub key on a server.

bash
# On the VPS, as the user that runs the app
ssh-keygen -t ed25519 -C "deploy@sample-app" -f ~/.ssh/sample_app_deploy
cat ~/.ssh/sample_app_deploy.pub

In GitHub, open the repository's Settings → Deploy keys, click Add deploy key, paste the public key and leave Allow write access unticked. Then tell SSH to use that key for GitHub and clone:

bash
cat >> ~/.ssh/config <<'CONF'
Host github.com
  IdentityFile ~/.ssh/sample_app_deploy
  IdentitiesOnly yes
CONF

sudo apt install git        # Debian/Ubuntu; on AlmaLinux or Rocky: sudo dnf install git
git clone [email protected]:your-user/sample-app.git ~/apps/sample-app

Create the .env file on the server by hand. It isn't in the repository, which is the point.

For each release:

bash
cd ~/apps/sample-app
git pull --ff-only
npm ci --omit=dev          # or: composer install --no-dev, pip install -r requirements.txt
sudo systemctl restart sample-app

--ff-only refuses to merge if someone edited files directly on the server, which is what you want: fix it in Git, not on the server. Replace the build and restart lines with whatever your app uses. The systemctl line assumes you run the app as a systemd service.

Automate it when you deploy often

Once the manual steps work, a GitHub Actions workflow can run them for you on every push to main. See GitHub Actions CI/CD deploy to a VPS.

7. Running this on Domain India

The editing and GitHub steps are the same everywhere. What changes is the deploy step:

Where the app runsHow you deploy
Domain India VPSEverything in section 6 works. The VPS is self-managed, with full root access
App PlatformConnect the GitHub repository and click Deploy Now, or deploy with a deploy token from your CI. Node.js is detected automatically; other languages need a Dockerfile
cPanel, DirectAdmin or Webuzo shared hostingJailed SSH is available on request (off by default, key login). cPanel also has Git Version Control. Composer and npm builds don't run there, so build locally and upload
Windows (Plesk) hostingNo SSH. Build locally and upload with FTP

The shared hosting routes are covered step by step in Deploying your website with Git. For the App Platform, start with Getting started with the App Platform.

8. Where Domain India fits

If you want a server of your own for this workflow, a VPS gives you full root access, so any Git workflow works. If you would rather not manage a server, the App Platform deploys from GitHub for you, from ₹100 a month. Domain India list prices on 19 September 2026, excluding 18% GST.

VPS Starter
₹552.65/mo + GST
  • 1 vCPU
  • 2 GB DDR4 RAM
  • 64 GB NVMe SSD Storage
  • 2 TB Monthly Bandwidth
See plan details
App Starter
₹100/mo + GST
  • 512 MB RAM per app
  • 1 vCPU
  • 5 GB NVMe SSD
  • PostgreSQL Database
See plan details

Frequently asked questions

Do I need to install Git separately from VS Code?

Yes. VS Code has Git buttons built in, but it uses the Git program installed on your computer. Install Git for Windows on Windows, the developer tools on macOS, or the git package on Linux, then restart VS Code.

Why does GitHub reject my password when I push?

GitHub no longer accepts account passwords for Git operations. Sign in through VS Code's browser login, use Git's credential manager with the HTTPS URL, or add an SSH key to your GitHub account and use the SSH URL.

What is a deploy key?

A deploy key is an SSH key attached to a single GitHub repository instead of to your account. Adding it without write access lets a server clone and pull that one repository and nothing else, which is safer than copying your personal key to the server.

Why does git pull fail on my server?

Usually because files were edited directly on the server, so Git cannot fast-forward. Run git status to see which files changed, move those changes into your repository on your computer, then discard them on the server and pull again.

Can I use this workflow with Domain India shared hosting?

The editing and GitHub steps are the same. For the deploy step on shared hosting, ask support to enable jailed SSH (it is off by default and uses key login), or use cPanel's Git Version Control, or build locally and upload. Composer and npm builds don't run on shared hosting.

Can Domain India deploy automatically from GitHub?

The App Platform can deploy from a connected GitHub repository when you click Deploy Now, or from your CI using a deploy token. On a VPS, you can automate deploys yourself with GitHub Actions.

Ready to deploy? Compare VPS plans for full control, try the App Platform to deploy from GitHub without managing a server, or open a ticket to ask for jailed SSH on your hosting account.

Deploy from GitHub without managing a server

Connect your repository, click Deploy Now, and your app is built and served over HTTPS.

See App Platform plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app