This is a continuation of a tutorial blog series to learn the basics of Git, using GitHub and the GitHub client.
To start from the beginning, go here.
Publish a new repository
Time to put your project online!
GitHub makes it easy to share your code with others online!
To publish your local repository, click the “Publish Repository” button in the upper right hand corner.
Once your project is linked to an online repository, the publish button will change to a “Sync” button.
After you’ve made a new commit, the Sync button will show that your local repository is ahead of the current online one.
Now you can reach the latest code for your projects from any computer with an internet connection.
Clone an existing repository
To download an existing repository to your computer, you have to “Clone” it.
GitHub’s client makes it easy to clone any repository tied to your GitHub account. Click the new repository button, and hit the “Clone” tab.
You can get to other repositories by going to GitHub.com. On the side of every public project page on GitHub, you’ll see these two buttons:
If you just want to download the files, you can go for the zip. But if you would like to be able to look at past commits, and commit your own changes, click the “Clone in Desktop” button and GitHub will automatically request to open your GitHub client.
Choice a place to save the files in, and now you have your own copy of that repository on your local machine!
Fork an existing repository
“Forking” is similar to cloning, but GitHub automatically links your new cloned repository to the original repository from which it came from.
Using your web browser on GitHub‘s website, there is a “Fork” button on the top right of project pages.
Forking a project adds a new repo to your account, which you can then clone to your local machine in GitHub’s client. You can make whatever changes you would like to your version of the repository, and it won’t affect the original.
Why would you want to do this? Because now you work on your own code and modifications without worrying about messing up someone else’s code (or their code messing with yours). Then when you’re ready, you can make a pull request to merge those changes back in.
Let’s say you want to work on an open source project. You decide to add a new feature to make the project even better.
You could clone it and work on your own new repo, which you may or may not share with others. Instead, you should work on a fork of the original project.
Then when you’ve finished making your changes and want to push them back into the original project for others to use, you can make a new “Pull” request. GitHub has a system for this built right into the website.
You can add documentation of exactly what you added and why, and the repository owner can check all the changes before making them officially part of the original repository.
That’s how you can contribute to the projects of others, and that is one of the basis of how open sourced software is built! Now you too can be an open source developer.
End of Part 2