Skip to content

✅ Add only modified files to the staging area

License

Notifications You must be signed in to change notification settings

thiagodp/restage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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