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