diff --git a/hands_on/force_push.py b/hands_on/force_push.py new file mode 100644 index 0000000..62b2c05 --- /dev/null +++ b/hands_on/force_push.py @@ -0,0 +1,25 @@ +import os +from exercise_utils.cli import run_command +from exercise_utils.git import add_remote, remove_remote +from exercise_utils.github_cli import clone_repo, create_repo, get_github_username + +__requires_git__ = True +__requires_github__ = True + +REPO_NAME = "gitmastery-samplerepo-things" +UPSTREAM_REPO = "git-mastery/samplerepo-things" +WORK_DIR = "things" + + +def download(verbose: bool): + create_repo(REPO_NAME, verbose) + clone_repo(UPSTREAM_REPO, verbose, WORK_DIR) + os.chdir(WORK_DIR) + remove_remote("origin", verbose) + + add_remote( + "origin", + f"https://github.com/{get_github_username(verbose)}/{REPO_NAME}", + verbose, + ) + run_command(["git", "push", "-u", "origin", "master"], verbose)