Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Existing Directory as Repository in GIT

I have a directory say cplusplus_learn and my username is apex_user (say) in git. Inside cplusplus_learn, there are some files and directories which I am practising C++ language. I want to make a repository of same name as cplusplus_learn and push every thing in GITHUB website. 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

github-error-repository-not-found-fatal

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.

like image 858
Dr. Essen Avatar asked Jun 04 '16 06:06

Dr. Essen


2 Answers

First you need to login in to your github account and create a repository with the name 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

$ 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 :)

like image 81
lightup Avatar answered Sep 30 '22 13:09

lightup


  • Add your SSH Key into Github profile setting.
  • Create a repository on Github. For example (RepoName)
  • Navigate into your project directory cplusplus_learn.
  • Initialize the 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
like image 33
Shravan40 Avatar answered Sep 30 '22 12:09

Shravan40