github cli 创建远程仓库并推送到github

这篇具有很好参考价值的文章主要介绍了github cli 创建远程仓库并推送到github。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

以下操作基于macOS,其他系统安装请参阅官方文档cli/cli: GitHub’s official command line tool。

1. 安装github cli

brew install gh

2. 登录

以下操作步骤基本上就是上下方向键进行选择,然后回车。Token需要访问这里手动创建并粘贴。Token的权限应该至少包括repo, read:org, admin:public_key.

# 输入登录命令
gh auth login
# 选择登录网站GitHub.com
? What account do you want to log into?  -> GitHub.com
# 选择协议,我选SSH
? What is your preferred protocol for Git operations?  -> SSH
# 选择并上传上传SSH public key
? Upload your SSH public key to your GitHub account?  -> /Users/simonliu/.ssh/id_rsa.pub
# 设置key的title
? Title for your SSH key:  -> GitHub CLI
# 选择认证方式,我这里选token
? How would you like to authenticate GitHub CLI?  ->Paste an authentication token
Tip: you can generate a Personal Access Token here https://github.com/settings/tokens
The minimum required scopes are 'repo', 'read:org', 'admin:public_key'.
? Paste your authentication token: ****************************************
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
✓ Authentication complete.

3. 在本地仓库文件夹创建远程仓库并推送到服务器

基本上就是输入 gh repo create然后一路根据提示操作即可。文章来源地址https://www.toymoban.com/news/detail-433473.html

# 3.1 创建远程 repository
gh repo create
# 3.2 输入本地仓库路径,默认是当前路径 .
? Path to local repository -> .
# 3.3 选择行为:推送本地仓库至github
? What would you like to do? -> Push an existing local repository to GitHub
# 3.4 设置仓库名称,注意不要使用中文,否则中文字符会被替换为英文破折号
? Repository name -> epub_convert_tool
# 3.5 输入描述
? Description -> epub转换工具
# 3.5 选择可见度
? Visibility -> Private
✓ Created repository simonliu009/epub_convert_tool on GitHub
# 3.6 为本地仓库增加remote
? Add a remote? -> Yes
# 3.7 设置remote名称
? What should the new remote be called? -> origin
✓ Added remote git@github.com:simonliu009/epub_convert_tool.git
# 3.8 是否将当前分支的提交推送到origin,选择Yes
? Would you like to push commits from the current branch to "origin"?  ->Yes
Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 3.61 KiB | 3.61 MiB/s, done.
Total 5 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), done.
To github.com:simonliu009/epub_convert_tool.git
* [new branch]      HEAD -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
✓ Pushed commits to git@github.com:simonliu009/epub_convert_tool.git

4. 其他gh命令

gh repo --help
Work with GitHub repositories.

USAGE
  gh repo <command> [flags]

GENERAL COMMANDS
  create:      Create a new repository
  list:        List repositories owned by user or organization

TARGETED COMMANDS
  archive:     Archive a repository
  clone:       Clone a repository locally
  delete:      Delete a repository
  deploy-key:  Manage deploy keys in a repository
  edit:        Edit repository settings
  fork:        Create a fork of a repository
  rename:      Rename a repository
  set-default: Configure default repository for this directory
  sync:        Sync a repository
  unarchive:   Unarchive a repository
  view:        View a repository

INHERITED FLAGS
  --help   Show help for command

ARGUMENTS
  A repository can be supplied as an argument in any of the following formats:
  - "OWNER/REPO"
  - by URL, e.g. "https://github.com/OWNER/REPO"

EXAMPLES
  $ gh repo create
  $ gh repo clone cli/cli
  $ gh repo view --web

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual

到了这里,关于github cli 创建远程仓库并推送到github的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Git 一份代码如何同时提交并推送到两个仓库

    博文目录 Git - 将一个项目同时从本地推送到 GitHub 和 Gitee 一份代码如何同时提交并推送到两个仓库, 需要明确从哪个仓库拉取代码 查看仓库绑定情况 再绑定另外一个远程仓库, 该仓库只推不拉 这时候执行推送, 大概率只能成功推到第一个仓库, 后绑定的仓库会拒绝, 要求先获

    2023年04月08日
    浏览(32)
  • 使用Git在本地创建一个仓库并将其推送到GitHub

     前记: git svn sourcetree gitee github gitlab gitblit gitbucket gitolite gogs 版本控制 | 仓库管理 ---- 系列工程笔记. Platform:Windows 10 Git version:git version 2.32.0.windows.1 Function: 使用Git在本地创建一个仓库并将其推送到GitHub 目录 一. 在本地创建一个GitHub仓库并将其推送到GitHub的步骤如下:

    2024年02月07日
    浏览(36)
  • git--新建项目并推送到远程(gitlab等)--方法/实例

    原文网址:git--新建项目并推送到远程(gitlab等)--方法/实例_IT利刃出鞘的博客-CSDN博客 本文用实例介绍如何新建项目并推送到远程(gitlab等)。 本文的方法适用于所有远程服务,包括:gitlab、gitee、github。 (一般只推送到一个远程即可,本文为了展示,会介绍多种远程git仓库的操

    2023年04月08日
    浏览(36)
  • Dockerfile快速搭建自己专属的LAMP环境,生成镜像lamp:v1.1,并推送到私有仓库

    环境: CentOS 7 Linux 3.10.0-1160.el7.x86_64 具体要求如下: (1)基于centos:6基础镜像; (2)指定作者信息; (3)安装httpd、mysql、mysql-server、php、php-mysql、php-gd; (4)暴露80和3306端口; (5)设置服务自启动。 (6)验证镜像。 步骤 ①创建项目目录 ②创建Dockerfile ③构建 Docke

    2024年02月11日
    浏览(25)
  • 试图将更改推送到 GitHub,但是远程仓库已经包含了您本地没有的工作(可能是其他人提交的修改)

            这通常是由于其他人或其他仓库推送到了相同的分支上,导致您的本地仓库和远程仓库之间存在冲突。 To github.com:8upersaiyan/CKmuduo.git ! [rejected] main - main (fetch first) error: failed to push some refs to \\\'github.com:8upersaiyan/CKmuduo.git\\\' hint: Updates were rejected because the remote contains wor

    2024年02月14日
    浏览(36)
  • GitHub操作之远程仓库基本操作(团队内创建,推送,拉取等)

    itHub是一个面向开源及私有软件项目的托管平台,因为只支持Git作为唯一的版本库格式进行托管,故名GitHub GitHub可以托管各种git库,并提供一个web界面,但它与外国的SourceForge、Google Code或中国的coding的服务不同,GitHub的独特卖点在于从另外一个项目进行分支的简易性。为一个

    2024年02月10日
    浏览(42)
  • 初始本地仓库推送到远程仓库-git

    下面的git的操作符合的情况是: ①本地初始化一个仓库,但是还没有和远程仓库相关联; ②远程仓库也刚刚创建,里面啥也没有 然后目前就想将本地的仓库的内容和远程仓库相关联并推送到远程仓库里面。

    2024年02月04日
    浏览(40)
  • Git 新建本地仓库,推送到远程仓库

       项目根目录出现  .git 隐藏文件夹。这个目录是 Git 来跟踪管理版本库的,没事千万不要手动修改这个目录里面的文件,不然改乱了,就把Git仓库给破坏了。 远程仓库地址 git status 查看目录情况 注: \\\".\\\"号前面有空格,\\\".\\\"表示所有文件 回车之后会显示提交的内容, git sta

    2024年02月07日
    浏览(53)
  • git 将本地仓库推送到远程仓库

    1.本地项目:   1.   git init    2.git add .  3. git commit -m \\\'xxxxx\\\' 2.在github 新建1 个仓库,在执行以下命令把远程仓库和本地仓库做一个关联 例子: git remote add origin 远程仓库地址 git push -u origin master   //本地仓库上传到了github 三、如果遇到这种代码报错: error: remote origin alre

    2024年01月24日
    浏览(42)
  • github上clone下来别人仓库的源码,如何推送到自己的仓库

    前提:对方项目开源,未有密钥 原文 如果你clone下来一个别人的仓库,在此基础上完成你的代码,推送到自己的仓库可能遇到如下问题: error: remote origin already exists.表示远程仓库已存在。 因此你要进行以下操作: 1、先输入 git remote rm origin 删除关联的origin的远程库 2、关联

    2024年02月16日
    浏览(28)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包