Skip to content

Instantly share code, notes, and snippets.

@seankross
Created February 5, 2014 18:26
  • Star 30 You must be signed in to star a gist
  • Fork 19 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save seankross/8830032 to your computer and use it in GitHub Desktop.
Initializing GitHub repository

Create a new repository on the command line

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/seankross/womp.git
git push -u origin master

Push an existing repository from the command line

git remote add origin https://github.com/seankross/womp.git
git push -u origin master
@BarbzYHOOL
Copy link

BarbzYHOOL commented Mar 5, 2018

The remote used is a SSH one and not HTTPS, can change it easily though. If using SSH, it requires SSH keys (and it won't ask for password, so that's useful)

curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPONAME"}'
git remote add origin git@github.com:USER/REPONAME.git
git push origin master

@InTEGr8or
Copy link

Please make sure you have the correct access rights
and the repository exists.

I don't think this creates the remote repository on the server. It just creates a remote pointer in the local git repo.

@Neptune998
Copy link

Neptune998 commented Oct 10, 2019

After following above instructions...

https://github.com/Neptune998/C_Code.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/Neptune998/C_Code.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

@cgthayer
Copy link

2020: Github doesn't support creating repos quite out-of-the-box (you need the UI). But I believe enterprise users can use REST or GraphQL:
https://developer.github.com/enterprise/2.20/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment