1

I'm new to GitHub. In recent days I was troubled by how to update files to GitHub.

All I want to do is upload file/files I specified to update(or override) existed file on Git remote repo without build other branches.

I try to search answer from web, but the answers are not I expected.
Because of personal reasons, I need frequently update the same file many times.

I sincerely hope someone could help me work out this question.
One of my senior students suggested me use git rebase origin/master to achieve this, but it only worked once. When I try to do like this again, Git prompts me: "there has a revision".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
joe Qi
  • 77
  • 5

1 Answers1

1

As described here, you can use a command-line command like http, from HTTPie in order to create a new commit with your file updated.
You need to base64 your file first, as seen here.

openssl base64 -in myFile.txt > myFile.txt.base64
http PUT https://api.github.com/repos/<me>/<my-Repo>/path/to/myFile.txt \
  "Authorization: token REDACTED-TOKEN" \
  message="my commit message" \
  committer:="{ \"name\": \"Me\", \"email\": \"me@users.noreply.github.com\" }" \
   attachedFile=@myFile.txt.base64 \
   attachedFileContentType=text/plain

Replace "me", "my-Repo", "path/to/myFile.txt" by your own values.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250