JBTM-1617. Move rebase code from narayana.sh to separate file (master)