def git_pattern_handle_blanks(git_pattern: str) -> str:
    """
    Trailing spaces are ignored unless
    they are quoted with backslash ("\").
    in fact all spaces in gitignore CAN be escaped
    it is not clear if they NEED to be escaped,
    but it seems like !
    see: https://stackoverflow.com/questions/10213653
    wcmatch.glob.globmatch supports both forms

    >>> assert git_pattern_handle_blanks(r'something \\ \\ ') == 'something\\ \\ '
    >>> assert git_pattern_handle_blanks(r'something \\ \\  ') == 'something\\ \\ '
    >>> assert git_pattern_handle_blanks(r'some\\ thing \\ ') == 'some\\ thing\\ '
    >>> assert git_pattern_handle_blanks(r'some thing \\ ') == 'some thing\\ '
    """
    parts = [part.strip() for part in git_pattern.split("\\ ")]
    return "\\ ".join(parts)