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:
What are the key terms a developer should know to understand GitHub?
- 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?
- 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 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?
- 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.
- GitHub CLI:
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
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.
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.
- 1000logos. 2021. "GitHub Logo." 1000logos, November 23. Accessed 2022-01-04.
- Apache Kafka. 2021. "Apache Kafka." Apache Kafka, on GitHub, December 22. Accessed 2021-12-22.
- Awesome GitHub Alternatives. 2021. "Awesome GitHub Alternatives." ianchanning/awesome-github-alternatives, on GitHub, November 27. Accessed 2022-01-04.
- Beer, Brent. 2018. "Introducing GitHub." Second Edition, January. O’Reilly Media, Inc. Accessed 2021-12-21.
- Catone, Josh. 2008. "GitHub Gist is Pastie on Steroids." Sitepoint, July 24. Accessed 2021-12-21.
- Chambers, Dakota. 2018. "Git vs. The Competition." Blog, April 17. Accessed 2022-01-04.
- Costello, Jason. 2013. "New GitHub Logo." Blog, GitHub, April 16. Accessed 2022-01-04.
- Friedman, Nat. 2020. "GitHub is now free for teams." The GitHub Blog, April 14. Accessed 2021-12-21.
- Git. 2021. "GUI Clients." Git. Accessed 2021-12-25.
- GitHub. 2017. "GitHub best practices." Resources, GitHub, September 22. Accessed 2022-01-04.
- GitHub. 2021. "GitHub Features." GitHub. Accessed 2021-12-25.
- GitHub CLI. 2022. "gh repo clone." Manual, GitHub CLI. Accessed 2022-01-05.
- GitHub Desktop. 2021. "Download GitHub Desktop." GitHub Desktop. Accessed 2021-12-22.
- GitHub Docs. 2021a. "Supported browsers." GitHub Docs. Accessed 2021-12-21.
- GitHub Docs. 2021b. "GitHub Mobile." GitHub Docs. Accessed 2021-12-21.
- GitHub Docs. 2021c. "Creating a branch." GitHub Docs. Accessed 2021-12-21.
- GitHub Docs. 2021d. "About repository." GitHub Docs. Accessed 2021-12-21.
- GitHub Docs. 2021e. "Inviting collaborators to a personal repository." GitHub Docs. Accessed 2021-12-22.
- GitHub Docs. 2021f. "Fork a repo." GitHub Docs. Accessed 2021-12-22.
- GitHub Docs. 2021g. "Example: Contribute to an existing repository." GitHub Docs. Accessed 2021-12-22.
- GitHub Docs. 2021h. "About READMEs." GitHub Docs. Accessed 2021-12-22.
- GitHub Docs. 2021i. "Cloning a repository." GitHub Docs. Accessed 2021-12-25.
- GitHub Docs. 2021j. "About pull requests." GitHub Docs. Accessed 2021-12-25.
- GitHub Docs. 2021k. "About branches." GitHub Docs. Accessed 2021-12-28.
- GitHub Docs. 2021l. "Merging a pull request." GitHub Docs. Accessed 2021-12-28.
- GitHub Docs. 2021m. "GitHub glossary." GitHub Docs. Accessed 2021-12-28.
- GitKraken. 2021. "Git Pull vs Fetch." GitKraken, Problems & Solutions, May 28. Accessed 2022-01-04.
- Holman, Zach. 2010. "One Million Repositories." The GitHub Blog, July 25. Accessed 2021-12-21.
- Holman, Zach. 2011. "Introducing GitHub Enterprise." The GitHub Blog, November 1. Accessed 2021-12-21.
- Jones, Jamie. 2018. "Getting Going and Best Practices Guide." GitHub Gist, May 3. Accessed 2022-01-04.
- McKenzie, Cameron. 2018. "Git vs. GitHub: What is the difference between them?" TheServerSide, TechTarget, November 6. Accessed 2022-01-04.
- NC State University. 2022. "GitHub Best Practices." GitHub at NC State, NC State University. Accessed 2022-01-04.
- Preston-Werner, Tom. 2008. "GitHub Turns One!" The GitHub Blog, October 19. Accessed 2021-12-21.
- Sahoo, Sunil Kumar. 2019. "How to Update a Fork in Git." Blog, on Medium, December 2. Accessed 2022-01-04.
- The Turing Way. 2021. "Using more GitHub features." The Turing Way, December 16. Accessed 2022-01-04.
- Warren, Tom. 2018. "Microsoft completes GitHub acquisition." The Verge, October 2018. Accessed 2021-12-21.
- Wauters, Robin. 2013. "Github turns five and hits 3.5 million users, 6 million repositories." The Next Web, April 2013. Accessed 2021-12-21.
- Zilberman, Eyar. 2018. "Top 10 GitHub best practices for developers." Datree, on Medium, October 24. Accessed 2022-01-04.