Log inSign up

Git on a server guides

Install Git, work with branches, undo mistakes and deploy with hooks. 7 guides in this topic.

Install and configure Git

Install Git from the distribution packages, set your identity and sensible defaults, and reach remote repositories over SSH with a key.

Clone, commit, push and pull

The everyday Git loop on a server: clone a repository, stage and commit changes, push them to the remote and pull what others wrote.

Create, switch, merge and delete branches

Work on features in separate branches: create and switch with git switch, merge them back, track remote branches and tidy up old ones.

Rebase and cherry-pick

Replay a branch on top of main with git rebase, clean up commits with interactive rebase, and copy single fixes between branches with cherry-pick.

Undo with reset, revert and stash

Throw away edits with restore, move a branch back with reset, cancel pushed commits with revert, park work with stash and rescue anything with the reflog.

Git submodules

Embed one repository inside another at a fixed commit: add, clone recursively, update to newer commits, change the URL and remove a submodule cleanly.

Deploy with a bare repository and hooks

Push to a bare repository on your VPS and let a post-receive hook check out the code, build it into a release folder and restart the service.