我正在通過 Vercel 部署我的 Vite 應用程式。
其中一個依賴項是 Github 中的私有存盤庫,
因此我創建了個人令牌并在 package.json 中提供了它
"dependencies": {
...
"my-private-repo": "git https://<personal_access_token>:[email protected]/myusename/my-private-repo.git"
},
我已經嘗試構建,在本地一切似乎都很好
但是,在 Vercel 構建中,它向我拋出了這個:
error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads https://<personal_access_token>:[email protected]/myusename/my-private-repo.git
所以我發現這git ls-remote是真正的問題
這是我git ls-remote使用令牌運行的時候
git ls-remote https://<personal_access_token>:[email protected]/myusename/my-private-repo.git
>>> remote: Invalid username or password
這是我在git ls-remote沒有令牌的情況下跑步的時候
git ls-remote https://github.com/myusename/my-private-repo.git
>>> 9a1daaf0faa44d30afd22121cb8da061d25d9044 refs/heads/main
由于這是一個私人回購,為什么git ls-remote只有在沒有提供憑證時才起作用?Github 是不是很奇怪?
如何在 Vercel 配置或 Github 配置中解決這個問題?
uj5u.com熱心網友回復:
為什么 git ls-remote 只在沒有提供憑據時才起作用,因為這是一個私人倉庫?
因為您的本地憑證助手在其中快取了憑證。
git config --global credential-helper
xxx
# replace xxx by the actual value
# check what is cached with:
printf "host=github.com\nprotocol=https" | git credential-xxx get
您可以暫時洗掉那些:
# replace 'You' with the account seen in the previous get command
printf "host=github.com\nprotocol=https\nusername=You" | git credential-xxx erase
然后在本地重試該git ls-remote https://<personal_access_token>:[email protected]/命令進行測驗。
如此處所示,還請查看以下語法是否更好:
git ls-remote https://oauth2:[email protected]/username/repo.git
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/493150.html
