Pushing local repository to remote repository using python Github The code should do the following in order:

It should download/clone the public Github repository locally.
It should remove all the git history (and branches)
Use the Github API to create a new Github repository initialized with the input github repository content that you downloaded locally. The new repository should be named using name supplied.
I am able to do steps 1 and 3 but asks for log-in 2 times. I am not able to initialize the new remote repo with local repo. local_repo = repo1 how? And removing git history? where can I find git history in the cloned repo.

import git,os,tempfile,os,fnmatch,sys
from github import Github

username = sys.argv[1]
password = sys.argv[2]
input_repo_url = sys.argv[3]
output_repo_name = sys.argv[4]

tempdir=tempfile.mkdtemp(prefix=&quot;&quot;,suffix=&quot;&quot;)
predictable_filename = &quot;myfile&quot;
saved_umask = os.umask(77)

path = os.path.join(tempdir,predictable_filename)
print(&quot;Cloning the repository at &quot;+path)

local_repo = git.Repo.clone_from(input_repo_url,path, branch=&quot;master&quot;)
print(&quot;Clone successful!&quot;)

g = Github(username,password)
user = g.get_user()
repo1 = user.create_repo(output_repo_name)
print(&quot;New repository created at &quot;+username+&quot; account &quot;)
print(repo1)

target_url = &quot;https://github.com/&quot;+username+&quot;/&quot;+output_repo_name+&quot;.git&quot;
print(target_url)

print(&quot;Pushing cloned repo to target repo&quot;)
local_repo.create_remote(&quot;new&quot;,url=target_url)
local_repo.git.push(&quot;new&quot;)
print(&quot;Success!!&quot;)
Octal permission fields
77

is likely incorrect. What you've written is 77 in decimal, but this would work out to 115 in octal. If you wanted 077 in octal, you would actually need to write 0o077.
Pathlib
Consider replacing os.path with use of pathlib.
Argument parsing
The argv parsing that you've done is fragile - it will fail with an invalid-index exception if the user provides insufficient parameters. Consider using argparse instead.
Also: do not ask for a password as part of a command line, since it will be stored in the user's shell history. Accept it from an environmental variable, a secure wallet, or from stdin via getpass (not input).
String interpolation
&quot;https://github.com/&quot;+username+&quot;/&quot;+output_repo_name+&quot;.git&quot;

is more easily written as
f'https://github.com/{username}/{output_repo_name}.git'