toe-pose
toe-pose

Reputation: 143

Leave git bash open after running script

I have a .sh script with the following code

cd C:/Users/... && git add . && git commit -m "QC" && git push && read

and the read command at the end does not keep the window open afterwards. Adding the read command worked for the following:

cd C:/Users/... && git pull && read

It runs and leaves the window open for me to read after pulling. Can anyone help me with the former script so it stays open after the commit so I can read it?

Upvotes: 2

Views: 702

Answers (1)

LeGEC
LeGEC

Reputation: 51820

You are combining all your commands with &&, so if any of your commands fail, the following commands (including read) will simply not be executed.

For example : if there is no change in your repo, git commit (as in your git commit -m "QC" command) will exit with code 1.


Just run read unconditinally :

cd .. && git add . && ... && git push
read

# if you really want to see your script on one line: '...; read'

Upvotes: 5

Related Questions