Domain 2: Introduction to GitHub

Domain 2: Introduction to GitHub

What is GitHub?

GitHub is a cloud-based platform that uses git, a distributed version control system as its core. GitHub simplifies collaboration on projects allowing users to work together.

AI

Generative AI is transforming software development. GitHub Enterprise enhances collaboration with AI-powered pull requests, boosts productivity with Copilot, and improves security with automated checks.

Collaboration

Collaboration is key at GitHub. We offer tools like Repositories, Issues, and Pull Requests to help teams work faster, reduce approval times, and ship quickly.

Productivity

GitHub Enterprise boosts productivity with automation. Integrated CI/CD tools handle routine tasks, allowing developers to focus on creating innovative solutions.

Security

GitHub integrates security into the development process from the start. GitHub Enterprise includes built-in security features to reduce risks, keeping your code private within your organization. You can also use Security Overview and Dependabot. GitHub is trusted by Microsoft and regulated industries, meeting global compliance standards.

Scale

GitHub is the largest developer community, with data on over 100M developers and 330M repositories. We adapt to developers' needs and evolve our platform accordingly. GitHub Enterprise focuses on enhancing the developer experience with unmatched scale, collaboration, productivity, security, and AI in one platform.

Now let’s explore the backbone of GitHub, repositories.

What is a repository?

A repository contains all of your project’s file, data and each file’s revision history. It’s one of the essential part that allows to collaborate with people. You can manage your file’s history, trac changes, store and work with others.

You can create a new repository on your personal account or any organization where you have sufficient permissions.

  1. In your home interface, you will find something like this. Name your repo from here.

  2. Choose a repository visibility.

    • Public repositories are accessible to everyone on the internet.

    • Private repositories are only accessible to you, people you explicitly share access with, and, for organization repositories, certain organization members.

  3. Select Create a new repository and congratulations! You just created a repository!

How to add a file to your repository

The main purpose of files is to store data and information about projects.

  1. after creating your repo, click on add file

  2. name your file, edit, go to preview, click on commit, add commit message

  3. Congrats! Your repo now contains a file!

What are gists

gists are a simpflied way to share code snippets with others. Every gist is a git repository. You can fork it, clone it, public it or secret it. Public gists are also searchable. For secret gists, it can be visit via the URL.

What are wikis?

Every repository on GitHub.com has a wiki for hosting documentation. Use it to share detailed content about your project, like usage, design, or core principles. While a README gives a quick overview, a wiki offers more in-depth documentation.

If your repository is private, only those with read access can view your wiki.

Components of the GitHub flow

  • Branches

  • Commits

  • Pull Requests

  • The GitHub Flow

What are branches

Branches are very essential because you do all the experiments on the branch. You can think of it as experimental branches as you wish. If you make any mistake you can revert to the previous or you and push more changes to fix the issue. The best part is, your changes and experiments won’t be updated in the default branch unless you merge so.

What are commits

A commit is a change to one or more file on a branch. Every time a commit is made, it’s assigned with a unique ID, its commit time and contributor. Commit always provides a transparent audit trail to anyone reviews the history.

In a git repo, file can exist in several states as it slides through version control process. The primary states are tracked and untracked.

Untracked: The initial stage of a file where it hasn’t yet recognized, means git is still unaware of it.

Tracked: The file which git is actively monitoring. A file undergoes through the following:

  1. Unmodified: The file has been tracked but has not been modified since the last commit.

  2. Modified: The file has been modified since the last commit, but the changes aren’t yet staged for the next commit.

  3. Staged: The file has been modified and its changes has been added to the staging area, also known as index and they are ready to be committed.

  4. Committed: The file is in the repo database. It represents the latest committed version of the file.

What are pull requests?

A pull request is a mechanism that indicates a commit from one branch is ready to be merged into another branch.

The team member submitting the pull request asks reviewers to check the code and approve the merge. Reviewers can comment, add changes, or discuss further. Once approved, the source branch is merged into the base branch.

The GitHub flow

The GitHub flow is a simple workflow for safe experimentation using branching, pull requests, and merging.

  1. Create a branch to keep changes separate from the main branch.

  2. Make changes and deploy them to your feature branch to ensure they work in production.

  3. Create a pull request to get feedback from collaborators. Some repositories require approval before merging.

  4. Review and implement feedback from collaborators.

  5. Once satisfied with your changes, get your pull request approved and merge it into the main branch.

  6. Finally, delete your branch to indicate the work is complete and prevent accidental use of old branches.

That’s it, you’ve completed a GitHub flow cycle!

GitHub is a collaborative platform

Collaboration is GitHub's core. In the previous blog, we learnt how repositories helps us to maintain and organize work among a group of people. In this section, we will look into issues and discussion.

Issues

GitHub issues track down new ideas, bugs, feedbacks, tasks etc. Issues can be created in various ways. For now, we’ll create an issues from repo but keep in mind that issues can be created from:

  • An item in a task list

  • A note in a project

  • A comment in an issue or pull request

  • A specific line of code

  • A URL query

Creating an issue from a repository

  1. On GitHub.com, navigate to the main page of the repository.

  2. Select Issues

  3. The create an issue

    Add tile and submit!

Discussions

Discussions are for conversations that everyone can see and aren't about code. They allow open, easy talks in a public space.

In this section, we cover:

  • Turning on discussions in your repository.

  • Starting a new discussion and exploring different discussion categories.

  1. Go to settings

  2. Scroll down and you will find discussions

    Set up your discussion and you’re done!