Common Git Commands in cPanel & WHM

This article explains the most essential Git commands used within cPanel & WHM environments. It includes practical examples, usage notes, and best practices for cloning, committing, branching, merging, stashing, configuring Git, and working with remote repositories through both command line and the Git Version Control interface.ط

Git CommandscPanel GitVersion Control

~4 min read · Updated Feb 21, 2026

1. Introduction


Git is one of the most powerful version control systems available, and cPanel fully supports it through the Git™ Version Control interface located at cPanel » Files » Git™ Version Control. This guide covers the most common Git commands to help you get started quickly.


Important notes before starting:


  • Run all commands inside the repository folder.
  • If you encounter an error, run git status first.
  • To get help for any command, add --help (example: git clone --help).

2. Essential Git Commands


2.1 git clone — Download a repository


This command creates a full local copy of a remote repository.


git clone https://github.com/username/repo.git

For private repositories:


git clone https://username:[email protected]/username/repo.git

cPanel note: The Git Version Control interface provides the clone URL. For private repositories, configure SSH keys or a Personal Access Token.


2.2 git add — Stage changes


Moves changes into the staging area before committing.


git add file.txt      # Add a single file
git add .             # Add all changed files
git add -A            # Add all changes including deletions
git add -u            # Add only tracked files

Note: git add only stages changes — it does not commit them.


2.3 git commit — Save changes


git commit -m "Add homepage"

Open editor for a longer message:


git commit

Auto-stage + commit:


git commit -am "Commit message"

Tip: Use clear and meaningful commit messages.


2.4 git checkout — Switch branches or restore files


git checkout main          # Switch to main branch
git checkout -b feature    # Create + switch to new branch
git checkout -- file.txt   # Restore file to last committed version

Note: -b creates and switches to a new branch.


2.5 git rm — Remove files


git rm file.txt            # Remove file from Git + disk
git rm --cached file.txt   # Remove from Git only
git rm -r folder/          # Remove folder

2.6 git fetch — Download changes (no merge)


git fetch origin

View remote changes:


git log origin/main


2.7 git pull — Fetch + merge


git pull origin main
git pull

Note: Resolve conflicts manually if they occur.


2.8 git push — Upload changes


git push origin main
git push -u origin main     # Set upstream
git push --all              # Push all branches

cPanel note: Pushing triggers the post-receive hook, which can automatically deploy your site.


2.9 git branch — Manage branches


git branch                 # List local branches
git branch -a              # List all branches
git branch new-feature     # Create branch
git branch -d old-branch   # Delete branch
git branch -m old new      # Rename branch

2.10 git merge — Merge branches


git checkout main
git merge feature-branch

Resolve conflicts → git addgit commit.


2.11 git blame — See who changed each line


git blame index.php

2.12 git clean — Remove untracked files


git clean -n      # Preview
git clean -f      # Delete files
git clean -fd     # Delete files + directories

2.13 git config — Configure Git


git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --list

2.14 git stash — Temporarily save changes


git stash
git stash list
git stash pop
git stash apply
git stash clear

3. Golden Tips for Working with Git in cPanel


  • Always start with git status.
  • Run git pull before making changes.
  • Set up SSH keys for private repositories.
  • Pushing triggers automatic deployment in cPanel-managed repos.
  • Use a proper .gitignore file.
  • Be consistent with commit messages.

Conclusion


These essential Git commands provide a strong foundation for working with Git inside cPanel & WHM. With practice, you can manage repositories, collaborate efficiently, and automate deployments with ease.


Written & researched by Dr. Shahin Siami

Related Articles

How to Restore Your cPanel Account: A Complete Guide for New System Administrators

This guide explains how new system administrators can restore a cPanel account using WHM, transfer accounts and configurations between servers, and enable diagnostic logging for transfer and restore operations. It covers essential concepts such as WHM vs. cPanel, root access, backup handling, SFTP uploads, transfer methods, and advanced debugging tools.

Continue

آموزش کامل انتقال تمام اکانت‌های cPanel از یک سرور به سرور دیگر

این مقاله نحوه انتقال همه اکانت‌های cPanel، تنظیمات سرویس‌ها، گواهی‌های SSL و IP اصلی سرور را از یک سرور قدیمی (Source) به یک سرور جدید (Target) توضیح می‌دهد. شامل نصب سرور جدید، انتقال تنظیمات، انتقال اکانت‌ها، تغییر IP، تنظیم DNS و نصب مجدد SSL است.

Continue

How to Migrate a WordPress® Installation to a cPanel & WHM Server

This guide explains how to migrate a WordPress installation from a macOS-hosted environment to a cPanel & WHM server. It covers exporting the database, uploading WordPress files, creating and importing a MySQL database, updating URLs, configuring wp-config.php, fixing broken links, and finalizing the migration.

Continue

How to Manually Transfer an Account Between Servers in cPanel & WHM

This article explains how to manually transfer a cPanel account between servers when the account is too large for WHM’s automated transfer tools. It covers creating temporary directories, compressing public_html and log files, securely transferring data with SCP, and restoring the files on the destination server.

Continue

How to Manually Migrate Horde Calendars and Contacts to Roundcube in cPanel & WHM

This article explains how to manually migrate Horde calendars and contacts to Roundcube in cPanel & WHM version 108 through 118. It covers exporting Horde data, placing it in the correct directories, and importing it into Roundcube using built‑in plugins or manual import tools.

Continue

How to Manually Migrate Accounts to cPanel & WHM from Unsupported Control Panels

This article explains how experienced system administrators can manually migrate accounts from unsupported third‑party control panels to cPanel & WHM. It covers pre‑migration steps, installation requirements, file and directory transfers, database restoration, SSL migration, and post‑migration tasks.

Continue