【问题标题】:how to push local repo to github from vscode wtithout creating repo on github?如何在不在 github 上创建 repo 的情况下将本地 repo 从 vscode 推送到 github?
【发布时间】:2022-01-27 07:18:47
【问题描述】:

是否可以将本地创建的文件夹推送到github而不先在github上创建相应的repo?

我的步骤:

  1. 在 vscode 中创建 2 个 py 文件
  2. git 初始化
  3. git 添加。然后 git commit 然后 git push

它仍然要求我在 github 上提供 repo 的链接。 如何从 VSCode 中指定 repo 名称然后推送它,以便它会自动在 github 上创建它?

【问题讨论】:

  • 简短的回答是“否”:VonC 的较长回答为您提供了一种在 GitHub 上创建存储库的方法从命令行,但您仍在创建首先是 GitHub 上的 repo。这是必需的。

标签: git github visual-studio-code


【解决方案1】:

你可以:

从那里,您可以使用 VSCode 中的 gh repo create 命令。

在存储库的根文件夹中打开一个终端,然后输入:

echo "my_GitHub_token" | gh auth login --with-token
gh repo create myNewRepo --source=.

重点是:使用CLI 'gh',您可以直接从您的工作站执行大多数与 GitHub 相关的操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-20
    • 2013-08-14
    • 1970-01-01
    • 2020-11-17
    • 2023-03-26
    • 2013-08-30
    • 2012-08-01
    相关资源
    最近更新 更多