---
title: "Use Git on GitHub for version control and · Agent Wranglers"
url: https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/git-on-github
updated: 2026-10-21
licence: "All rights reserved"
---

# Use Git on GitHub for version control and code hosting

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- Level: Recommended
- Chapter: [Delivery and infrastructure](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure)
- Rule: Keep every repository in Git, hosted on GitHub, with the default branch protected.
- Cost: Free tier. Git is open source under GPL-2.0. GitHub is proprietary, free for public and small private projects and paid above that.
- How: Git has been in use since 2005 and released 2.56.0 on 28 September 2026. It is free software under the GPL-2.0 licence. GitHub launched in 2008 and is the most used collaboration tool in the Stack Overflow Developer Survey 2025, at 81.1% of all respondents. Every AI coding tool knows Git commands and the GitHub pull request flow. The way out is simple, because `git clone --mirror` copies the full history to any other host. Protect the main branch as [Protect the main branch](https://agentwranglers.se/playbook/engineering/version-control-and-review/protect-the-main-branch) says. We keep GitHub as the pick even though it is proprietary. GitLab Community Edition is open source under MIT and includes CI. Hosting it yourself means running, backing up and upgrading a large server, and AI tools know the GitHub flow best. Choose something else when you must host code on your own servers. Then pick GitLab Community Edition. GitLab came third in the same survey at 35.6%.
- Check: `git --version` on every developer machine and CI runner prints a release from the last six months. A mirror clone of each repository to a second host finishes without errors, run in the last 12 months.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### Shell example

```sh
git clone --mirror git@github.com:example/shop.git
cd shop.git && git push --mirror git@backup.example.com:example/shop.git
```

### YAML example

```yaml
# .github/CODEOWNERS is plain text, the branch rule lives in the repository settings
# Export the settings as code with the GitHub API so a move keeps them
branch: main
required_reviews: 1
required_checks: [test]
```

## Sources

- [Git](https://git-scm.com/)
- [About protected branches](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches)

## Related rules

- [Protect the main branch](https://agentwranglers.se/playbook/engineering/version-control-and-review/protect-the-main-branch) in Engineering

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/git-on-github">Agent Wranglers software choices playbook</a>`. In code you write, add a comment next to it with the same link.

- Next: [Use GitHub Actions for continuous integration](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/github-actions-ci)
- [Delivery and infrastructure](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure)
