# Git and GitHub for Infrastructure Work

> Use Git to version scripts, Terraform and pipeline files, collaborate through pull requests and keep secrets out of repositories. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/cloud-engineer/git-basics
Last updated: 2026-11-28

Use Git to version scripts, Terraform and pipeline files, collaborate through pull requests and keep secrets out of repositories.

Beginner · about 5 hours · difficulty 1/5

Learn first: [Linux Command Line for Cloud Servers](https://www.internhack.in/roadmaps/tracks/cloud-engineer/linux-cli)

Modern cloud teams treat infrastructure like software: everything lives in Git, changes go through pull requests and pipelines deploy from the main branch. You need Git before Infrastructure as Code or CI/CD make sense.

### The essentials

- **init, clone, add, commit, push, pull**: the daily loop.
- **Branches**: work on a feature branch, merge through a pull request.
- **diff and log**: see exactly what changed and when.
- **.gitignore**: keep build output, .terraform folders and local state files out.

### Collaboration on GitHub

- Pull requests with review before merge.
- Branch protection on main (require reviews and passing checks).
- Issues and READMEs to explain how to run your project, which recruiters read.

### Secrets and Git

Never commit AWS access keys, .env files or Terraform state with passwords. Bots scan public GitHub for AWS keys within minutes and start crypto-mining on your account. If you leak a key, **deactivate it in IAM immediately**, then clean history. Deleting the file in a new commit is not enough.

### Pitfalls

- Huge commits with messages like "changes".
- Force-pushing to a shared branch.
- Committing terraform.tfstate, which can contain secrets.

You are ready to move on when you can create a repo, work on a branch, open a pull request, merge it and explain why a leaked key in an old commit is still a risk.

## Key concepts

- **Commit, branch, merge**
- **Remotes, push and pull**
- **Pull requests and code review**
- **.gitignore**
- **Keeping secrets out of Git**
- **git-secrets / secret scanning**
- **Rebase vs merge**

## Mini project

Create a public GitHub repo called cloud-notes. Add your Linux script and CIDR plan from earlier topics, a .gitignore, and a README. Enable secret scanning and branch protection on main, then make one change through a pull request.

## Check yourself

You pushed an AWS access key to a public repo and then deleted it in the next commit. Are you safe? What should you do?

## Free resources

- [Pro Git (free)](https://git-scm.com/book/en/v2) (git-scm.com)
- [GitHub Docs](https://docs.github.com/en) (GitHub)
- [Git and GitHub roadmap](https://roadmap.sh/git-github) (roadmap.sh)

Previous: [DNS and How Domains Reach Your Servers](https://www.internhack.in/roadmaps/tracks/cloud-engineer/dns-basics) · Next: [Creating and Securing Your AWS Account](https://www.internhack.in/roadmaps/tracks/cloud-engineer/account-setup)

## More in Linux, Networking and Git Fundamentals

- [Linux Command Line for Cloud Servers](https://www.internhack.in/roadmaps/tracks/cloud-engineer/linux-cli)
- [Networking Fundamentals: IP, CIDR, TCP and Ports](https://www.internhack.in/roadmaps/tracks/cloud-engineer/networking-basics)
- [DNS and How Domains Reach Your Servers](https://www.internhack.in/roadmaps/tracks/cloud-engineer/dns-basics)
- [Git and GitHub for Infrastructure Work](https://www.internhack.in/roadmaps/tracks/cloud-engineer/git-basics)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cloud Engineer (AWS) Roadmap](https://www.internhack.in/roadmaps/tracks/cloud-engineer)
