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