Creating Github repo from either remote or locally.
Two ways of creating a GitHub repository
There are two ways to create a Github repository. One is pushing from local to remote, another is pulling from remote to local.
1. Create a repo on Github and Clone it to local
- Create a repo on Github
- Go to the project, find a URL
- Go to your local folder, run command
git clone URL
2. Create a local repository, push it to your Github account
- Go to your Github page, create a new repository, select Push an existing repository, get your repo address
- Create a directory to contain the project, go into this directory
git initto initialise it as a Git Repository
- You’ll probably want to create a
git add .and
git commit -m "Commit message"
- In your local, run
git remote add origin REPO_URL. You can get your REPO_URL from
git remote -v
- Push your code:
git push -u origin YOUR_BRANCH, in this case can be
git push -u origin master
3. Configure remote url
# works without internet \$ git config --get remote.origin.url # works with internet \$ git remote show origin
Last Updated: Dec 2019