Code Sharing on Github

Octocat

Push your code to GitHub using the command line

On your GitHub profile click “new repo”, give it a name, brief description, choose the “public” repo option, and click “create repository”. In the command line, make sure you cd into your project folder and type:

$ git init

This initializes a git repository in your project. Next check if a file called READEME.txt exists in your project directory. If the file doesn’t exist, create it by typing:

$ vim README.txt

Then type:

$ git status

This will list out all the files in your working directory.

Then type:

$ git add .

This adds in all of your files & changes so far to a staging area.

Then type:

$ git commit -m "first commit"

This commits all of your files, adding the message “first commit”

Next type:

$ git remote add origin https://github.com/username/project_name

Your GitHub Repository page will list the repository URL. You can copy and paste the link from your GitHub repository page by clicking the clipboard icon next to the URL.

This creates a remote, or connection, named “origin” pointing at the GitHub repository you just created.

Then type:

$ git push -u origin master

This sends your commits in your “master” branch to GitHub

Congratulations your code is on GitHub!

Updating a local repository with changes from a Github repository

$ git pull origin master

@Happy sharing.

Advertisements

Published by

kaurdavinder

I am the one who discover myself daily through reading, writing, interacting with people and expressing my thoughts to inspire them if I would be able to bring a little change to the society through my work. I write blogs, participate in various social activities and want to be a Professional Speaker. Currently, I am pursuing my post graduation in Computer Applications from Guru Nanak Dev Engineering College, Ludhiana and I’m very much active in many technical & social communities.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s