简体   繁体   English

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

[英]Create Existing Directory as Repository in GIT

I have a directory say cplusplus_learn and my username is apex_user (say) in git . 我有一个目录说cplusplus_learn ,我的用户名是apex_user (说)在git中 Inside cplusplus_learn, there are some files and directories which I am practising C++ language. 在cplusplus_learn中,有一些我正在练习C ++语言的文件和目录。 I want to make a repository of same name as cplusplus_learn and push every thing in GITHUB website. 我想创建一个与cplusplus_learn同名的存储库,并在GITHUB网站上推送所有东西。 Can someone please explain me the complete steps for doing that. 有人可以向我解释完成这一步骤的完整步骤。 I went through various links but totally confused. 我经历了各种各样的链接但完全糊涂了。 Mostly says that there is already repo is made. 大多说已经有回购。

convert-existing-non-empty-directory-into-a-git-working-directory 转换存在,非空目录到-A-混帐工作目录

github-error-repository-not-found-fatal GitHub的错误-库未找到致命

Note: All things I want to do from terminal . 注意:我想从终端做的所有事情。

$ 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

Given above is what I tried. 以上就是我试过的。 I know there is something wrong but I can't figure that out. 我知道有什么不对,但我无法弄明白。

First you need to login in to your github account and create a repository with the name cplusplus_learn 首先,您需要登录您的github帐户并创建名为cplusplus_learn的存储库

All things I want to do from terminal. 我想从终端做的所有事情。 Just as you have already described. 就像你已经描述过的那样。 From your description, it seems that you have a wrong remote url already set so you need to update or reset it as shown below 根据您的描述,您似乎已经设置了错误的远程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

Hopefully this should work. 希望这应该工作。 Thanks :) 谢谢 :)

  • Add your SSH Key into Github profile setting. 将SSH密钥添加到Github配置文件设置中。
  • Create a repository on Github. 在Github上创建一个存储库。 For example (RepoName) 例如(RepoName)
  • Navigate into your project directory cplusplus_learn . 导航到项目目录cplusplus_learn
  • Initialize the git git init . 初始化git git init
  • git remote add origin https://github.com/apex-user/RepoName.git
  • git add -A
  • git commit -m "Message you would like to put"
  • git push origin master

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

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