在 GIT 中创建现有目录作为存储库

Ac3*_*t3R 5 git github ubuntu-16.04

我有一个目录说cplusplus_learn,我的用户名是git 中的apex_user(比如说)。在 cplusplus_learn 里面,有一些我正在练习 C++ 语言的文件和目录。我想创建一个与cplusplus_learn同名的存储库,并将所有内容推送到 GITHUB网站。有人可以向我解释这样做的完整步骤。我浏览了各种链接,但完全困惑。主要是说已经有回购了。

将现有非空目录转换为 git-working 目录

github-error-repository-not-found-fatal

注意:我想从终端做的所有事情。

$ cd cplusplus_learn
$ git init .
$ git commit -m 'My first commit'
$ git remote add origin https://github.com/apex-user.git
fatal: remote origin already exists.
$ git push -u origin master
fatal: repository 'https://github.com/apex-user/' not found
Run Code Online (Sandbox Code Playgroud)

上面给出的是我尝试过的。我知道有问题,但我无法弄清楚。

lig*_*tup 5

首先,您需要登录到您的 github 帐户并创建一个名为 cplusplus_learn 的存储库

我想从终端做的所有事情。正如你已经描述的那样。根据您的描述,您似乎已经设置了错误的远程 url,因此您需要更新或重置它,如下所示

$ cd cplusplus_learn
$ git init 
$ git commit -m 'My first commit'
$ git remote set-url origin https://github.com/apex-user/cplusplus_learn.git
$ git push -u origin master
Run Code Online (Sandbox Code Playgroud)

希望这应该有效。谢谢 :)