Skip to content

Instantly share code, notes, and snippets.

@alexpaul
Last active September 25, 2019 18:07
Show Gist options
  • Save alexpaul/71888780c41228b5f3370b8cbd079dad to your computer and use it in GitHub Desktop.
Save alexpaul/71888780c41228b5f3370b8cbd079dad to your computer and use it in GitHub Desktop.
Steps to create a local repo using git init and push to a remote Github repo

Steps to create a local repo on your machine using Terminal and push to Github

Create Folder in Terminal

  1. mkdir "ProjectFolder"

Github.com

  1. Navigate to Github.com and create a new repository
  2. Enter the repo name
  3. Enter an optional description
  4. DO NOT create a README, .gitignore or license in this step
  5. Click on the Create repository button

Follow the Steps on Github "create a new repository on the command line" to complete the process

  1. Navigate inside the created Folder in Terminal cd ProjectFolder
  2. echo "# Heading for the README file" >> README.md
  3. git init (creates a new local repository)
  4. git add README.md (prepares the file in prepartion for versioning)
  5. git commit -m "first commit" (adds to version control)
  6. git remote add origin <newly created repo url goes here without the angle brackets> (start trackeing repo at given url location) git
  7. git push -u origin master (uploads all local commits to to Github, the -u flag sets the upstream)

At this point if all went well you should be able to refresh your Github page and see your newly created repo 🚀

What's Next

The alternative approach would be to create the Github repo then use git clone <repo url> to your local machine using Terminal at a desired location. At this point you can add files, folders as needed and push to Github.

Reading Resources

Github Cheatsheet
Github Glossary
Git Documentation

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