繁体   English   中英

如何使用 git 仅使用令牌从 cli 创建 github 存储库?

[英]How to create a github repository from the cli with git using only a token?

使用 github 令牌,我发现使用新存储库的最简单方法是。

1. Create the new repo on the github site.
2. git clone https://[user]:ghp_asdcsdcasdcasdcasdcasdcasdc@github.com/[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]:ghp_asdcsdcasdcasdcasdcasdcasdc@github.com/[user]/repo-name.git

但这完全失败并出现错误:

remote: Repository not found.
fatal: repository 'https://github.com/[user]/repo-name.git/' not found

所以官方的方式被打破了(因为它假设密码认证会起作用,但密码认证在 2021 年 8 月被删除了)。

在 cli 中,如何在我的帐户下创建存储库(使用令牌,而不是密码),然后开始将更改推送到该存储库?

这有效,但不能完全从 cli 完成该过程,需要在站点上执行此步骤。

如果您在本地安装了GitHub CLI gh ,则无需在站点上执行任何步骤

然后你可以:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM