Adding local code to github

Github is a great source of sharing your code with other developers. It allows you to create free repositories online.

Follow the steps below to create a repo on github and upload your code to that repo to make it public

Go to GitHub and create account there or login.

Create a new repo by hitting the + icon on top bar. I have created “instagram-php” repo.

Note: Keep “Initialize this repository with a README” unchecked

Copy the HTTPS url of that repo.

Open terminal

Go to your source code directory and initialize a repo

$ cd /htdocs/instagram-php
$ git init
$ git add --all
$ git commit -m "Instagram API for PHP using Guzzle"

Use the HTTPS url you copied earlier from github to create a remote origin

$ git remote add origin

Push your code to github repo

$ git push -u origin master


If you encounter an error like “fatal: refusing to merge unrelated histories”, that error appears when you create a repo on github by initializing readme file.
Here is the solution


Leave a Reply

Your email address will not be published. Required fields are marked *