I need a help with this:
I want to loop the git status code without status code or together status code in one line; I'm using the code below:
# file.sh
files=$(git status --porcelain)
for file in $files; do
echo $file
done
# OUTPUT
M
example_folder/example_file
M
example_folder_1/example_file_1
M
example_folder_2/example_file_2
....
The problem is the status code always displays, I need to remove the status code or put it together like this:
# LINES EXPECTED
M example_folder/example_file
M example_folder_1/example_file_1
# OR
example_folder/example_file
example_folder_1/example_file_1
My objective is to output an input using console, like this:
files=$(git status --porcelain)
for file in $files; do
echo $file
git add $file
read -p "enter a comment: " comments
git commit -m "${comments}"
done
The code above is working, but the status code received the comment too, and I need to remove or put it in one line each line modified.
regards.