Reputation: 48644
Imaging I have two different branches:
Now I have written a shell script in branch branch1
named sync.sh
(Note that sync.sh
is added and committed to that branch) which has following statements:
git checkout branch2
#Now perform some operations on branch2 like pull, commit something and push
git checkout branch1
#Again perform some operations on branch1
Now my question is will this work ? Because when it is switched to branch2
, there will be no script in the filesystem on it. So will it execute properly? On my attempt, it seems to be working. But can this thing be relied upon ?
Upvotes: 0
Views: 43
Reputation: 80921
Assuming the script doesn't need to re-execute itself or refer to itself from disk then yes you can count on this.
The script will already be running. The running shell has the file open and will continue to read from it until the script finishes.
Upvotes: 1