I'm writing a bash script to add, commit, push all files in a directory.
#!/bin/bash git add . read -p "Commit description: " desc git commit -m $desc git push origin master
I'm getting the following error:
$ ./togithub Commit description: test commit script error: pathspec 'commit' did not match any file(s) known to git. error: pathspec 'script"' did not match any file(s) known to git. Everything up-to-date
I'm not sure if this is a problem with reading in the text (it echo
s fine) or passing it to git commit -m
.
To add a Git commit message to your commit, you will use the git commit command followed by the -m flag and then your message in quotes. Adding a Git commit message should look something like this: git commit -m “Add an anchor for the trial end sectionnn.”
Git Bash is an application for Microsoft Windows environments which provides an emulation layer for a Git command line experience. Bash is an acronym for Bourne Again Shell. A shell is a terminal application used to interface with an operating system through written commands.
You have to do:
git commit -m "$desc"
In the current script, test
is going as commit message and commit
and script
are being treated as next arguments.
Here's a merge of the last two answers - chaining together the add -u is awesome, but the embedded read command was causing me troubles. I went with (last line used for my heroku push, change to 'git push origin head' if that's your method):
#!/bin/bash read -p "Commit description: " desc git add . && \ git add -u && \ git commit -m "$desc" && \ git push heroku master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With