Tuesday 10 November 2015

Version control ethics with GitHub

The following post is going to cover the standard procedure of contributing to a project hosted by an individual or an organization on GitHub.


  1. Search for the project or open the project you are invited to & fork the repository to your account.
  2. A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.
  3. To fork a repo, you will see a "Fork" button on the righter side. Click that. 
  4. Clone the repo to your local machine using GitShell or any git client.
  5. Contribute to the project the way you want. Keep in mind the standards of coding while contributing to a collaborated project.
    A code must not only be smart but also beautiful. A beautiful code is a readable code. This is a must when working in a team so that your fellow mates can understand what you want to do and what they have to do further. Google about coding standards to know more.
  6. Once your module is ready, do not push it directly to master branch. Generally, as a contributor you don't have the permission to commit changes in the master branch of the repository. When you fork a repository, there ought to be a maintainer and/or an owner who takes care of what goes in the master branch of the original repository. Whatever changes you make in the forked repository does not affect the original repository until and unless it is permitted by the owner/maintainer.
  7. So you create your own version of the module and push the code there. This version is called a branch.
  8. Create a branch of any name you want by,
    git branch <branchname>
  9. To change the current branch type,
    git checkout <branchname>
    Refer to the tutorials posted in the earlier post for a clearer idea of this.
  10. Once you have added all your untracked files to your own branch, git push it all.
  11. Now your copy of the module is updated to the forked repository, to merge your branch with the master branch, you need to generate a pull request to the owner.
  12. To generate a pull request, open up your forked repository and click "Pull request" on the righter side, click on "New pull request" and select your branch in one drop down while the master in the other. It will show all the changes you made with respect to the other branch.
  13. Type in the essential commits and comments and generate the request to merge your branch with the master branch.
  14. If the owner/maintainer finds the pull request sufficing then he might merge your branch with master. Else they will comment the problems. Once merged with the master branch, they might open Issues with your request which you will have to solve.
GitHub has bridged the gap between coders overseas. If all is followed correctly, a greatly collaborated teamwork can be exercised online using version control software like GitHub.
Hit the +1 if you like my post, comment your views and confusions.

Start forking, start contributing!

Sunday 8 November 2015

GitHub

Have you ever worked on Google Docs? It has got a feature of adding collaborators to your document and multiple people, wherever they might be, can edit the document at the same time, parallel to each other. You can even see the cursor of the other collaborators moving in real time with a history of edits made by every collaborator in a timeline.

When people work in teams to code on large projects, it becomes hard to keep the work collaborated on everyone's side. Copying all the files from one's computer and pasting it on his. Thereafter he has to read every line of code and change the edits he made which can be tedious and wastes a lot of time.

_________________________________________________________________________

So there is a term called "version control". 

"Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later."  

Google about version control to know more about it.

Git comes into picture here.


"Git (/ɡɪt/) is a widely used version control system for software development."

Git was initially developed and designed by Linus Torvalds, father of Linux. A very popular platform for Git repository hosting is GitHub.

"GitHub is a Web-based Git repository hosting service"

More than 29 million projects are hosted on GitHub at present, with more than 11 million users. The beautiful part about this is that you can fork in the open-source projects and contribute to it and others can contribute in yours.
_________________________________________________________________________

SETTING UP GITHUB :

GIT TERMINOLOGY :

This will be a quick terminology introduction before you start using GitHub :
  • GIT : Git is an open source program for tracking changes in text files.
  • REPOSITORYA repository is the most basic element of GitHub. They're easiest to imagine as a project's folder.
  • COLLABORATOR : A collaborator is a person with read and write access to a repository who has been invited to contribute by the repository owner.
  • CONTRIBUTOR : A contributor is someone who has contributed to a project by having a pull request merged but does not have collaborator access.
  • BRANCH : A branch is a parallel version of a repository. It is contained within the repository, but does not affect the primary or master branch allowing you to work freely without disrupting the "live" version. When you've made the changes you want to make, you can merge your branch back into the master branch to publish your changes.
  • CLONE : A clone is a copy of a repository that lives on your computer instead of on a website's server somewhere, or the act of making that copy. With your clone you can edit the files in your preferred editor and use Git to keep track of your changes without having to be online.
  • PULL : Pull refers to when you are fetching in changes and merging them. For instance, if someone has edited the remote file you're both working on, you'll want to pull in those changes to your local copy so that it's up to date.
  • PUSH : Pushing refers to sending your committed changes to a remote repository such as GitHub.com. For instance, if you change something locally, you'd want to then push those changes so that others may access them.
  • COMMIT : The changes you made in your repository are not in your repository yet. We could add or remove files from the stage before we store them in the repository.
    To store our staged changes we run the commit command with a message describing what we've changed. So basically, it records the changes to the repository.
Once you are clear with these terminologies, you are ready to go make your own Git repos and start adding collaborators and contributors and host an online repo and work on a perfectly collaborated project. To learn about the syntax of using GitShell, you will find the following videos very helpful. Thanks to LearnCode.academy for these videos.

  1. GitHub Tutorial part 1
  2. GitHub Tutorial part 2

An amazing way to perform your first Git commands is through https://try.github.io/ This a is very fine tutorial provided by GitHub itself. Do try it out! 

Enjoy forking and hosting repos!

Click here to get an idea of how to use GitHub if you want to contribute in projects. >> Version control ethics with GitHub