> ## Content Index
> Fetch the complete content index at: https://securinglaravel.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Security Tip: Selectively Stage and Commit Changes
- URL: https://securinglaravel.com/security-tip-selectively-stage-and/
- Published: 2021-12-11T02:00:49.000Z
- Updated: 2024-10-10T06:03:20.000Z
- Description: [Tip#10] You should always selectively stage changes, to avoid committing secrets or debug code and pushing to prod.
- Author: Stephen Rees-Carter
- Tags: Security Tips, git

When committing changes into version control, you should always selectively stage your changes first before committing. This allows you to manually review every line of code you commit, to ensure any secrets ([API keys, passwords, etc](https://securinglaravel.com/security-tip-app-config)) or debug code isn’t added.

This is super easy in Git:

```
git add -p
```

You can also selectively stage specific files:

```
git add -p <file>
```

I’ve even taken it a step further with some Git aliases:

```
git addp  =>  git add -p
git addc  =>  git add -p && git commit -v
git acp   =>  git add -p && git commit -v && git push
```

Sometimes the changes are massive and take time to review, but if you’ve ever accidently pushed debug code onto prod, you’ll appreciate the time saved cleaning up that mess!

---

**Found this security tip helpful?* Don't forget to* [*subscribe*](https://securinglaravel.com/#/portal/signup) *to receive new* [*Security Tips*](https://securinglaravel.com/tag/tips/) *each week, and upgrade to a* [*premium subscription*](https://securinglaravel.com/#/portal/signup) *to receive monthly* [*In Depth articles*](https://securinglaravel.com/tag/in-depth/)*, or toss a coin in the* [*tip jar*](https://securinglaravel.com/#/portal/support)*.*

*Reach out if you're looking for a* [*Laravel Security Audit and Penetration Test*](https://stephenreescarter.net/laravel-security-audits-and-pentesting/?utm%5Fsource=securinglaravel.com) *or a budget-friendly* [*Security Review*](https://stephenreescarter.net/laravel-security-reviews/?utm%5Fsource=securinglaravel.com)*, and find me on the various socials through* [*Pinkary*](https://pinkary.com/@valorin?ref=securinglaravel.com)*. Finally, don't forget to check out* [*Practical Laravel Security*](https://practicallaravelsecurity.com/?utm%5Fsource=securinglaravel.com)*, my interactive security course.*