<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def git_handler(unused_build_context, target, fetch, package_dir, tar):
 """Handle remote Git repository URI. Clone the repository under the private builder workspace (unless already cloned), and add it to the package tar (filtering out git internals). TODO(itamar):
 Support branches / tags / specific commit hashes TODO(itamar):
 Support updating a cloned repository TODO(itamar):
 Handle submodules? TODO(itamar):
 Handle force pulls? """

    target_name = split_name(target.name)
    # clone the repository under a private builder workspace
    repo_dir = join(package_dir, fetch.name) if fetch.name else package_dir
    try:
        repo = git.Repo(repo_dir)
    except (InvalidGitRepositoryError, NoSuchPathError):
        repo = git.Repo.clone_from(fetch.uri, repo_dir)
    assert repo.working_tree_dir == repo_dir
    tar.add(package_dir, arcname=target_name, filter=gitfilter)