Updates git remote for the managed theme folder if has changed.

        :param git_repository: git url of the theme folder
        :param folder: path of the git managed theme folder

def update_git_repository(self, folder, git_repository):
        """Updates git remote for the managed theme folder if has changed.

        :param git_repository: git url of the theme folder
        :param folder: path of the git managed theme folder
        """

        # load repo object from path
        repo = git.Repo(folder)

        # keep local_head_name for to reset folder remote head later
        local_head_name = repo.head.ref.name

        # test if git repository url has changed
        remote = repo.remote('origin')
        if remote.url == git_repository:
            return

        # remove/add new remote repository origin
        remote.remove(repo, 'origin')
        origin = remote.add(repo, 'origin', git_repository)

        # fetch available branches
        origin.fetch()

        # get remote head according previously store local head name
        remote_head = getattr(origin.refs, local_head_name)
        # reset repository tracking branch according deduced remote head
        repo.create_head(local_head_name, remote_head)\
            .set_tracking_branch(remote_head)