I am writing a script that will do this:
#!/bin/bash mysqldump -u user -p database > db_file git add db_file git commit -m 'db_file updated by script'
However, what if the index is dirty when I run this script? That is, if I already git add edited files that I do not want to automatically execute when the script starts? I could do this:
#!/bin/bash mysqldump -u user -p database > db_file git stash git add db_file git commit -m 'db_file updated by script' git stash apply
But now the problem is that if the index and the working tree are not dirty, then git stash apply will not add anything to the list, but git stash apply will incorrectly apply everything that is on top of the plate and discard the history of this influx.
How can I make a bash condition based on the fact that the index is dirty?
source share