首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用git使用令牌从cli创建github存储库?

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

Stack Overflow用户
提问于 2021-10-28 04:21:43
回答 1查看 455关注 0票数 1

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

代码语言:javascript
运行
复制
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网站上提出)是:

代码语言:javascript
运行
复制
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

但是这个错误完全失败了:

代码语言:javascript
运行
复制
remote: Repository not found.
fatal: repository 'https://github.com/[user]/repo-name.git/' not found

因此,官方的方式被打破了(因为它假定密码身份验证将起作用,但密码身份验证在2021年8月被删除)。

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-28 05:58:59

这是可行的,但不能完全从cli执行过程,需要在站点上执行步骤。

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

然后你可以:

讨论中,OP确定如下:

使用gh创建回购: gh auth登录

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69748278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档