class Git::Branch
def in_branch (message = 'in branch work')
return true # auto commits and switches back
# do other stuff
# create new file
g.branch('new_branch').in_branch do
def in_branch (message = 'in branch work') old_current = @base.lib.branch_current checkout if yield @base.commit_all(message) else @base.reset_hard end @base.checkout(old_current) end