A Developers Blog: Using GitHub To Share Your Code Tutorial

This blog has moved to GitHub, and you should be redirected shortly...

Tuesday, April 14, 2015

Using GitHub To Share Your Code Tutorial

The purpose of this tutorial is to show you how to use GitHub to share your code with others.

For this tutorial we will be using GitHub for Windows. This tutorial does not go into full detail, but does provide all the steps that are needed for learning purposes.

In order to follow along with this tutorial, you will need to install GitHub for Windows. You can download the program from here: https://windows.github.com/, and you will need to create an account on GitHub here: https://github.com/. Creating an account is free, and only takes a few minutes.

If you have completed the previous steps, we can get started.

1. Open GitHub for Windows. Once the program is loaded you will need to input your account information for GitHub. Click on options and fill out the "Name" and "Email Address" sections under configure git. Next you need to click on the "add account" button, and enter your account details.


2. Make sure you save your changes. Now go to https://github.com/, and sign into your account. Once you do this, click on the "Create New Repository" button in the top right corner.


3. You will then want to enter a repository name, and enter some optional information, such as a description, a readme file, gitignore file, a liscense, and whether the repository is public or private. An example is posted below:


In order to make a private repository, you have to pay for a premium account. The .gitignore file is a file that will ignore certain files when you make commit changes to your repository. For this example, we will not be using one. You can find more information on the .gitignore here: http://git-scm.com/docs/gitignore

4. Click on the "Create Repository" button. Your repository has now been created.

5. Now, switch back to the GitHub for Windows program. Click on the "+" icon, and choose the "Clone" tab. You will now see a list of your repositories. Click on the repository that you just created, and click the "Clone repository" button.


6. A window will pop up, and ask you for a location to store your local repository. GitHub will now clone your repository onto your computer. Now you can add files to your repository, update any files that are in your repository, or even remove files from your repository.

7. Now navigate to where you told GitHub to store this repository on your computer. The default location is: C:\Users\yourUserName\Documents\GitHub. Once you find your repository folder, double click it, and choose to open the "README" file that is located there. This can be edited with Notepad, or a similar program.

If you did not choose to create a "Readme" file when you created your repository, that is okay. You can just add a file to to this folder and skip the next step.

8. Inside the "README" file, just edit the text inside the file, or add more text to the file. Save the file and close it.

9. Now switch back to the GitHub for Windows program and you should see a button that says "Uncommitted changes". It may take a moment for the program to update.



10. Click on the "Show" button, and a pop up will show a spot for a Summary and a Description. You will want to put in meaningful information here since these comments are kept with your repository, and can be reviewed in order to see what changes have been done to your repository.


11. Click on the "Commit to master" button. Once you do this, you need to click the "sync" button at the top right to update your repository.

12. Now, go back to the GitHub website, and go to the repository that you created. You should now see that it has been updated with the changes that you have made. Now you can share your files with anyone by giving them a link to that repository.

Summary: This tutorial showed you how to create a repository on GitHub, and how to commit changes to that repository using the GitHub for Windows program. While this was a simple example, you can do many powerful things with GitHub. For example, you can create branches so you have a master branch and a working branch, you can update your local version of the repository by syncing it with the master repository, and you can add contributors so your team members can make changes to the

I hope you enjoyed this tutorial. If you have any questions or comments, please feel free to post them below.

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home