我正在自动执行一项特定任务,其中将新文件夹添加到 git 存储库。 我正在从工作 git push 中复制 .git 文件夹。
我暂存了我想要推送的文件夹中的所有内容,然后当我推送它时一切正常,但是服务器上的 repo 中的其他 5 个文件夹已经消失,只有我的新暂存文件夹在那里。一旦我创建的文件夹在那里,它就会在本地被删除,所以我只想将此文件夹添加到存储库中,以便其他人可以使用。
我不想为了推送一个文件夹而每次都下载整个 repo。有没有办法做到这一点?
def gitPush(commit_message:str):
if not checkExists((staging_root) + '.git'):
return(".git folder not found, cannot push.")
else:
repo = Repo(staging_root + '.git')
repo.git.add(all=True)
repo.index.commit(commit_message)
origin = repo.remote(name='origin')
origin.push('master')
谢谢。