首页 > 解决方案 > 并非所有文件都使用 GitPython 传输到 Github

问题描述

我在 python 上使用以下代码推送到 git(忽略 async 和 ctx 部分):

    async def gitpush(self, ctx):
        try:
            repo = Repo(os.getcwd())
            repo.git.add(update=True)
            repo.index.commit("Committed")
            origin = repo.remote(name='origin')
            origin.push()
            await ctx.send("Git pushed!")
        except:
            await ctx.send("Some error occured while pushing..")

async def gitpull(self, ctx):
   g = git.cmd.Git(os.getcwd())
   g.pull()
   await ctx.send("Git pulled!")

但是,如果我这样做了,我添加/删除的文件就不会再出现在 repo 上。有没有办法将文件夹中的所有文件添加/推送到 github?

谢谢!

标签: pythongitgithub

解决方案


而不是update=True,放A=True


推荐阅读