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 https://github.com/your-github-username/instagram-php.git

Push your code to github repo

$ git push -u origin master

Issues

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

 

Advertisements

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