Linus Torvalds created Git in 2005 to manage the Linux kernel’s source code, and it has since become the standard tool for almost every software project. “Distributed” means every copy of a repository carries the full history, so you can work offline and sync later.
Core concepts
| Concept | Meaning |
|---|---|
| Repository | The project folder plus its history, stored in the hidden .git folder |
| Commit | A saved snapshot with a message and a unique ID |
| Branch | An independent line of work, so you can try a feature without touching the main branch |
| Merge | Bringing one branch’s changes into another |
| Remote | A copy of the repository elsewhere, such as GitHub or your server |
Example: an everyday workflow
git clone [email protected]:user/shop.git
cd shop
git switch -c fix-checkout
# ... edit files ...
git status
git add .
git commit -m "Fix checkout total"
git push -u origin fix-checkout
A .gitignore file lists what Git should never track:
.env
node_modules/
vendor/
Common mistakes and mix-ups
- Committing secrets: an
.envfile in the repository exposes your passwords to anyone with access. If it happens, change those passwords at once: deleting the file later doesn’t remove it from history. git pushrejected: usually the remote branch has commits you don’t have yet. Rungit pullfirst; details on the git push rejected page.- Merge conflicts: happen when two people edit the same lines. You resolve them by hand, then commit the result.
- Git is not a full backup: it doesn’t hold your database or the files visitors upload.
- Git is not GitHub: one is a tool, the other a hosting service: see GitHub.
On ArabyHost
AI/Developer plans include Git and a command line over SSH, jailed inside CageFS, so you can run git pull right on the server once you’ve added an SSH key to your GitHub account. cPanel also has Git Version Control for cloning a repository and running deployment steps from a .cpanel.yml file, as explained in the cPanel Git deployment guide. Your database and uploaded files are covered separately by daily JetBackup backups.
FAQ
What's the difference between Git and GitHub?
Git is the tool that runs on your machine and records changes. GitHub is a website that hosts Git repositories and adds review and collaboration on top. You can use Git without GitHub.
Should I commit node_modules or vendor?
No. Add them to .gitignore and reinstall dependencies on the server from package-lock.json or composer.lock.
How do I undo the last commit?
If you haven't pushed it, git reset --soft HEAD~1 removes the commit but keeps your changes. If you already pushed, use git revert, which adds a new commit that undoes it without rewriting history.