https://github.com/thiagodp/restage
✅ Add only modified files to the staging area
https://github.com/thiagodp/restage
area captain-hook git husky husky-php lint lint-staged php stage staged staging-area
Last synced: 2 months ago
JSON representation
✅ Add only modified files to the staging area
- Host: GitHub
- URL: https://github.com/thiagodp/restage
- Owner: thiagodp
- License: mit
- Created: 2023-10-16T19:46:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-07T23:19:13.000Z (12 months ago)
- Last Synced: 2025-03-04T13:37:36.602Z (3 months ago)
- Topics: area, captain-hook, git, husky, husky-php, lint, lint-staged, php, stage, staged, staging-area
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# restage
> ✅ Add only modified files to the staging area
**Use case**: You're using Git and your files are ready to commit. But when you run `git commit`, your `pre-commit` Git Hook runs a formatting tool that changes your files again. Now you have to run `git add` again, but only for the changed files, since you don't want to add untracked files yet. _That's boring, I know_. Fortunately, now you can use `restage` for that.
👉 `restage` adds only modified files to the staging area.
_Note_: There are similar tools for JavaScript, such as [lint-staged](https://github.com/lint-staged/lint-staged), that can be used for this purpose. `restage` aims at projects that do not need to use JavaScript.
## Install
> Requires only PHP 7.0+ and Git
```bash
composer require phputil/restage --dev
```## Usage
```bash
php vendor/bin/restage
```You probably want to include the above command into your Git Hook (e.g. `pre-commit`), to be executed after a command that formats your source code. For instance, `php vendor/bin/php-cs-fixer && php vendor/bin/restage`.
### CLI Options
```txt
--help This help.
--all, -a List untracked files and modified staged files.
--dry-run, -d Simulate the command without actually doing anything.
--modified, -m List modified staged files.
--verbose, -v Enable verbose mode.
```👉 If you wanna run a linter/formatter in modified files, you can use `--modified` to get them.
### Useful tools
- [Captain Hook](https://github.com/captainhookphp/captainhook) can manage your Git Hooks.
- [PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) can format your source code.
- [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an alternative to PHP-CS-Fixer.## License
[MIT](LICENSE) © [Thiago Delgado Pinto](https://github.com/thiagodp)