I'm new to Git.
My problem is, with a shell script (running in Windows) I need to save the Git Push commands to an output file.
So far i've something like this:
echo -e "\n6) ${GREEN}Starting Push.${NC}"
git push -v >> logs/logPush.log
if grep -q -w -i "Rejected" logs/logPush.log ;
then
echo "${RED}A conflict has been detected. Exiting.${NC}"
read
exit
else
:
fi
But it always generates a blank file. The Pull works just fine tho...
Does anyone know how to make the output file receive the whole information that it appears on the terminal:
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 289 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To ssh:repository
42be914..ead1f82 master -> master
updating local tracking ref 'refs/remotes/origin/master'
Redirect stderr to the file as well:
git push -v >> logs/logPush.log 2>&1
It looks like git push has the --porcelain option for this purpose:
--porcelain
Produce machine-readable output. The output status line for each ref will be tab-separated and sent to stdout instead of stderr. The full symbolic names of the refs will be given.
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