I am working on the GIT challenge and tried pushing my forked Patchwork remote to my own user account on GitHub (GH). It did not work, even after setting up my origins (fetch and pull) to the path of the repo.
Eventually, I got it working by going to GH and manually choosing Fork (from the source location) to create the repo under my username.
I don’t think that I should have do this to save my local repo to GH. In he past I always first create my repo on GH and then clone it from my local computer.
Is there a way to create a public repo from your local branch without first having to create the repo on GH?
You need to use the command line for this. In some editors you can access the command line directly from the editor (VS Code / Atom(via a plugin) - or you can open a command window for the folder your working in.
cd <github_repo>
git fork```
to make a new repo
https://help.github.com/articles/adding-a-remote/
to add your existing project(fork) to your new repo -
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
The commands (after forking) go something like this - i have these saved in the md of my project templates until they become "second nature".
```git init
git add .
git commit -m "init"
git remote add origin <URL>
git remote set-url origin <URL>
git remote -v
git push origin master```
Alternatively you can use github desktop software, but where's the fun in that!
I see, sorry i didn’t really answer your question did I. The only way is via CMD API or web interface.
You can use the GitHub API from the command line, and incorporate that.
something like so: (note curl is required (from Stack Overflow).
curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'
# Remember replace USER with your username and REPO with your repository/application name!
git remote add origin git@github.com:USER/REPO.git
git push origin master
Can never be bothered myself though so I just manually make the repo first seeing as i’m on the site a lot anyway its just a click on my faves bar. Everything else can be command line after that.
I had wanted to create the repo from my local machine without having to manually first create the repo on GH.
All my searching point me to go to the GH UI to create the repo and then use the url path to setup the remote address.
I will go with your suggestion and also use the creating a new repository as my guide.
@MARKJ78, type git version into the terminal, and see if you get versions for both git and hub, like this:
$ git version
git version 2.1.4
hub version 2.2.0
If you only get the git version then you need to follow the instructions at the top of the hub page to install hub and set an alias so that git actually calls the hub command.