使用 github 令牌,我發現使用新存盤庫的最簡單方法是。
1. Create the new repo on the github site.
2. git clone https://[user]:[email protected]/[user]/repo-name.git # Using token to authenticate
3. cd into that new folder and then put files in here and then add / commit / push
git add . ; git commit -m "test" ; git status ; git push -u origin master
這有效,但不能完全從 cli 完成該程序,需要在站點上執行此步驟。
但是,“官方”方式(在 github 站點上提供)是:
echo "# test-xxx" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/[user]/repo-name.git
git push -u origin master
顯然,密碼驗證不再可用,因此這會自動失敗。所以我將遠程添加源更新為git remove add origin https://[user]:[email protected]/[user]/repo-name.git
但這完全失敗并出現錯誤:
remote: Repository not found.
fatal: repository 'https://github.com/[user]/repo-name.git/' not found
所以官方的方式被打破了(因為它假設密碼認證會起作用,但密碼認證在 2021 年 8 月被洗掉了)。
在 cli 中,如何在我的帳戶下創建存盤庫(使用令牌,而不是密碼),然后開始將更改推送到該存盤庫?
uj5u.com熱心網友回復:
這有效,但不能完全從 cli 完成該程序,需要在站點上執行此步驟。
如果您在本地安裝了GitHub CLI,則無需在站點上執行任何步驟gh
然后你可以:
登錄 GitHub(從本地命令列):
gh auth login --with-token < mytoken.txt在 GitHub 上創建一個新存盤庫(從本地命令列):
git init my-project cd my-project gh repo create
在討論中,OP 決定:
使用
gh以下命令創建存盤庫:gh auth login --with-token < ~/.token git init my-project cd my-project gh repo create my-project --confirm --public cd ..; rm -rfi my-project; git clone --depth=1 https://[user]:[token]@github.com/[user]/[my-project]
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/341234.html
下一篇:Github頁面未顯示
