'How to append to a file using PyGithub?

I want to append to an already existing .txt file using PyGithub in Python. I have tried this code:

git = Github(TOKEN)
repo = git.get_repo("Repository")
file = repo.get_contents("Textfile.txt", ref="Ref")

repo.update_file(file.path, "test", "Text I wanna store", file.sha, branch="Ref")

but this code deletes the old data and only stores this data i.e. "Text I wanna store" only.

I want to store this data at the end of the previously stored data like "Previous Data Text I wanna store"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source