# GitHub

## Summary


GitHub is a hosting platform for managing source code. GitHub offers source code management with version control and collaboration features. With GitHub, developers have a platform to work together on projects from anywhere.

GitHub is widely used to host and manage open source projects. There's also a licensed version of GitHub named GitHub Enterprise, which allows organizations to install and manage GitHub servers in a data centre or on enterprise cloud. Irrespective of GitHub's freely available hosted version or the enterprise licensed version, its main purpose is to: 

* Facilitate version control of source code
* Track aspects of software development
* Collaborate using features such as Wikis, project boards, forking, pull requests and merging
* Provide uniformity in the developers' interaction with the platform

## Discussion

### What are the key terms a developer should know to understand GitHub?

We note a few terms: 

    + **Repository**: A place for source code and other files of a project.
    + **Clone**: Download a copy of a repository into a local machine to work on it independently.
    + **Fork**: Copy another's repository into one's own GitHub account. Users usually can't directly update repositories owned by others but can they make changes to the fork.
    + **Branch**: Isolates code changes. A repository can have multiple branches, each serving a specific purpose, such as a bug fix, feature development or experimentation. Each branch doesn't affect the work on other branches.
    + **Pull Request**: Describe the changes and request for a review. Applicable to branches and forks. However, they can be also be used to initiate feature discussions.
    + **Merge**: Take finished work from one branch into a target branch.
    + **Fetch**: Bring changes from a remote repository to the local copy but keep the local copy untouched.
    + **Pull**: A combination of fetch followed by merge.

### What are the key features of GitHub?

Key features of GitHub include but are not limited to: 

    + Distributed revision control, meaning that a clone is a complete copy and allows developers to work offline.
    + Collaboration features such as issues management, project boards, wikis, and adding reviewers to the changes being made in the repository.
    + Automation features such as auto labeling of issues, continuous integration, continuous deployment, and change approval based on events.
    + Team management features such as creating individual accounts, assigning individuals a custom role with defined permissions, inviting other members to collaborate on a repository, creating and assigning email notifications rules, and even imposing restrictions when so required.
    + Ability to check for code vulnerability in real time before it gets shipped to production
    + Other security features such as private repositories, two-factor authentication for user accounts, and security audit logs to track who has performed what actions and when.

### How is GitHub different from Git?

Git is a version control software whereas GitHub is a platform that enables multiple developers to collaborate on a project. 

Git is installed on the user's machine or a server. Typically, a developer installs Git client tools and starts working on the project. When changes are ready to be shared with others, the developer can push them to a shared online repository. GitHub is one such platform for sharing and collaboration. It's a web-based service that hosts Git repositories.

While Git is focused on version control, GitHub uses Git but also offers many features not native to Git: forking, online editing, branch protection rules, user and team management, encryption key management, email notifications, task tracking, project wikis, marketplace for third-party tools, and more. 

Git has its alternatives: Mercurial, Team Foundation Version Control (TFVC), Bazaar, CVS, SVN, Fossil, Perforce (Helix Core), and more. GitHub too has its alternatives. Amazon CodeCommit, Atlassian BitBucket and GitLab are some examples. Organizations can also create and maintain their own online platforms instead of using GitHub. This is called self-hosting. 


### What are the high-level steps involved in getting started with GitHub?

To get started with GitHub, a developer should have internet access to interact with the hosting platform. The developer can begin with these basic steps: 

    + Create a GitHub account
    + Create a repository or fork an existing repository
    + When creating a repository, control access using the visibility feature
    + Clone the repository, thereby making a local copy
    + Create a new branch
    + Add a new file: this can be any file, even a text file would do as a start
    + Commit and push the changes from local repository to remote repository on GitHub
    + Create a pull request, applicable when your GitHub repository is a fork another *upstream* repository
    + When others submit a pull request to your repository, review the pull request and merge it
    + Invite collaborators to contribute to the repository.

### What tools do I need to interact with GitHub?

A developer can use the following tools:

    + **Web Browsers**: GitHub platform is supported by the latest browser versions of Chrome, Firefox, Safari and Microsoft Edge.
    + **GitHub CLI**: A command-line tool, when installed in the user's system shall be used to interact with various features of the GitHub platform. Using GitHub CLI, a developer can create pull requests, manage bugs, and perform GitHub Actions.
    + **GitHub Desktop**: This is a GUI-based tool that simplifies the interaction with Git and performs actions related to GitHub branches, fetching or pulling changes into the local repository, committing the changes, and pushing the changes to the remote repository on GitHub.
    + **GitHub Mobile**: It's a mobile app compatible with Android and iOS devices, using which the users can manage notifications, collaborate on pull requests and issues, and interact with repositories in GitHub. GitHub Mobile app is currently in beta version and applicable for the GitHub Enterprise Server 3.0+ licensed versions.

### How can I maintain my project source code in the GitHub repository?

If the project involves only text files for version control, one can create and manage the files in the GitHub's user interface using the compatible browsers as a client-side tool. However, it's best to clone the repository to the local machine when the project involves a complex ecosystem such as a Java, Python or JavaScript-based web development. Cloning is also the solution when you want to group multiple file changes into a single commit. 

As a prerequisite to perform cloning and working on the repository, you should have a GIT client tool (GIT CLI or GitHub Desktop) installed in the system. To clone, you can do either of these:

    + **GitHub CLI**: `gh repo clone <userName>/<repoName>`
    + **Git Bash**: `git clone https://github.com/<userName>/<repoName>`Create a feature branch in the local repository and start adding the files to the project. Once the changes are done, commit them. Then push the changes to the remote GitHub Repository.


### What are the best practices when using GitHub?

One of the best practices is to have a README file at the root path of the repository. This should capture high-level project information. While creating the repository, the repository owner can choose a suitable license.

Write descriptive commit messages. Don't commit directly to the main branch. Instead use branch and create pull requests. Main branch should always be deployable. Commit with the right email address. Don't commit project dependencies or temporary build or log files. Don't commit configurations since these may hold passwords and other secrets. Many of these can be avoided by writing your `.gitignore` file correctly. 

Don't put passwords, API keys, SSH keys and other secrets in code. Secure your account with two-factor authentication (2FA). Use SSH keys and SSH Git URL, which are essential for 2FA. 

Lock package versions for all project dependencies. Use GitHub's Code Owners feature for faster reviews. This automatically selects reviewers. Another useful feature is GitHub Organizations for easier access control. 

GitHub has published a number of videos that share best practices in many areas: CI/CD, workflow strategies, managing projects, quality control, searching, getting insights, etc. 


### How can I contribute to open source projects in GitHub?

GitHub has a search feature allowing developers to look for suitable projects. Once you've selected a project, fork the repository. This allows you to carry out the changes without impacting the original repository.

Read and understand the project guidelines to ensure your contributions will meet the criteria defined. As an example, see the guidelines from the Apache Kafka project. 

Once the changes are made in the forked repository, create a pull request to the original project repository. Wait for the review comments from the original repository's collaborators. Address the review comments, if received any, and push the changes. Review gets done and your changes get merged to the original project repository.

Apart from feature development or fixing issues, there are other ways to contribute. These include documenting Wiki pages, providing clarification to issues reported by others, providing examples in the existing documentation, or enhancing the project's Readme file.

## Milestones

Oct  
2007

The **first code commit** is done towards the development of the GitHub hosting platform. 

Apr  
2008

**GitHub's website** is made available by Tom Preston-Werner, Chris Wanstrath, P. J. Hyett, and Scott Chacon. 

Jul  
2010

GitHub reaches a milestone of hosting one million repositories on its hosting platform. 

Apr  
2013

GitHub adopts a **new logo** along with a mascot named *Octocat*. Name in the logo capitalizes "G" and "H".   GitHub reaches a milestone of 3.5 million users. There are a total of 6 million repositories hosted on GitHub. 

Oct  
2018

**Microsoft acquires GitHub** on October 26, 2018. 

Apr  
2020

GitHub announces the creation and usage terms of **private repositories**. This is free with no limit on the number of collaborators. Also, users are now allowed to use all the core features of GitHub free of cost.