Reputation: 621
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.
Upvotes: 9
Views: 16508
Reputation: 31
Updated for 2023: This should be able to help you.
In your local folder through the command line, execute these list of commands:
git init
git add . && git commit -m "<Your commit name here>"
git remote add origin <Github repository URL>
(you can get it from your Github, and if you do not have a repository, you can create that with the help of gh repo create
command or on the Github website).git remote -v
git push --set-upstream origin master
You're all set!
Upvotes: 3
Reputation: 61
You could use the git hub cli https://cli.github.com/manual/gh_repo_create
Upvotes: 0
Reputation: 674
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 :)
Upvotes: 13
Reputation: 9908
cplusplus_learn
.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
Upvotes: 3