Push an existing local git repo to Github

This is something I regularly end up needing to do; maybe writing this down will help me remember how to do in future!

  1. If you haven’t already, create a new repo in Github
  2. From the comand line in your local project folder type: git init
  3. Include your new files in your local repo: git add .
  4. Step 3 also stages the files, so now commit them to your local repo: git commit -m "replace with your commit message"
  5. Get the https url of your GitHub repo and add this as your remote repo:
    • git remote add origin your_remote_repo_url
    • git remote -v
  6. Now push your local changes to your remote repo: git push -f origin master

Refresh your repo on GitHub and , hey presto, there’s all your files

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s