phputil/restage

Add only modified files to the staging area

Installs: 106

Dependents: 4

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:application

v0.4.1 2024-06-07 23:18 UTC

This package is auto-updated.

Last update: 2024-11-08 00:11:39 UTC


README

✅ 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, 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

composer require phputil/restage --dev

Usage

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

  --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

License

MIT © Thiago Delgado Pinto