Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to automate my workplace as much as I can, but I'm kind of new to bash scripts. What is the best way to tell bash script to run git co master and if it is successful do git pull and once it is finished do some other commands? I need to do this every morning at 7am (can I schedule it directly in bash script?)

share|improve this question

1 Answer 1

You can string together commands using && so:

#!/bin/bash
git co master && git pull && some_other_commands

To schedule, use cron if you are on Mac OS X or Unix/Linux.

The crontab entry would be:

* 7 * * * /path/to/your/bash/script
share|improve this answer
    
You could also check variable $? after running the command in an if statement to determine if it run successfully. –  Alex Nov 14 '13 at 20:29
    
Additionally, you might want to use git stash to preserve changes to the local repo that haven't been checked in yet. –  Roland Smith Nov 16 '13 at 23:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.