When using GitHub's APIs, we'll also see how to use an empty commit!
*Empty git tree SHA*: 4b825dc642cb6eb9a060e54bf8d69288fbee4904
You can save your token in the terminal by running: GITHUB_TOKEN={YOUR GITHUB TOKEN}
GitHub API calls I used:
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/{USER}/{REPO}/contents/empty_file.txt \
-d '{"message":"init the repository with an empty file","content":"", "branch": "tom"}'
----------
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/{USER}/{REPO}/git/commits \
-d '{"message":"commit message for the empty commit","parents":[],"tree":"4b825dc642cb6eb9a060e54bf8d69288fbee4904"}'
----------
*copy the commit SHA in GitHub's response*
----------
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/{USER}/{REPO}/git/refs/heads/tom \
-d '{"sha":"{THE COMMIT SHA OF YOUR NEW COMMIT}","force":true}'
----------
00:00-00:32 Intro
00:33-01:05 How to initialize a repository using the browser
01:06-03:01 How to initialize a repository using a git client
03:02-07:28 How to initialize a repository using GitHub's API
07:29-07:40 Thank you!
Auf dieser Seite können Sie das Online-Video How to Initialize an Empty GitHub Repository (Browser / Git Client / GitHub API) mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Software Engineer Tutorials 04 Juni 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 853 Mal angesehen und es wurde von 10 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!