pre-commit

Git pre-commit hook : changed/added files

青春壹個敷衍的年華 提交于 2019-11-26 12:14:04
I am writing a pre-commit hook. I want to run php -l against all files with .php extension. However I am stuck. I need to obtain a list of new/changed files that are staged. deleted files should be excluded. I have tried using git diff and git ls-files , but I think I need a hand here. araqnid git diff --cached --name-status will show a summary of what's staged, so you can easily exclude removed files, e.g.: M wt-status.c D wt-status.h This indicates that wt-status.c was modified and wt-status.h was removed in the staging area (index). So, to check only files that weren't removed: steve@arise:

How do I undo the most recent local commits in Git?

落花浮王杯 提交于 2019-11-25 21:35:37
问题 I accidentally committed the wrong files to Git, but I haven\'t pushed the commit to the server yet. How can I undo those commits from the local repository? 回答1: Undo a commit and redo $ git commit -m "Something terribly misguided" # (1) $ git reset HEAD~ # (2) << edit files as necessary >> # (3) $ git add ... # (4) $ git commit -c ORIG_HEAD # (5) This is what you want to undo. This does nothing to your working tree (the state of your files on disk), but undoes the commit and leaves the