1.6 - Domain:1 - Introduction to Git and GitHub
GitHub Foundations Certification
Hello Yatris, This guide will help you understand the basics of Git and GitHub, providing the knowledge you need to pass the GitHub Foundations Certification exam.
1. Git and GitHub Basics
What is Version Control?
Version control is a system that records changes to files over time so you can go back to specific versions later. It is essential for tracking the progress of projects, working with a team, and avoiding mistakes.
- Example: If you’re writing code, a version control system allows you to save different versions as you make changes. You can go back to an earlier version if needed.
What is Distributed Version Control?
Distributed version control means that every user has a complete copy of the project history, not just the latest version. This allows each user to work offline and share changes easily.
- Example: Git is a distributed version control system, so each developer has a full copy of the code on their own computer, not just a central server.
What is Git?
Git is a popular distributed version control system. It helps you keep track of changes in files and collaborate with others.
- Example: When you make changes to a project (like updating code), Git helps you save those changes, view the history, and go back to earlier versions if needed.
What is GitHub?
GitHub is a cloud-based platform that allows users to store, share, and collaborate on Git repositories online. GitHub provides features for team collaboration and project management, such as pull requests and issues.
- Example: GitHub acts as a website where developers can upload their Git projects so they can work on them together and track progress.
Difference Between Git and GitHub
- Git: The software used to track changes locally on your computer.
- GitHub: The website where you can store, share, and manage Git repositories with others.
2. GitHub Repository
What is a Repository?
A repository, or “repo,” is a storage space where a project’s files, folders, and history are stored. Each repository represents a separate project and contains files and folders for that project.
- Example: If you create a project to build a website, you might create a repository called “MyWebsite” to store all the code, images, and history for that project.
Practical Concept:
- To create a repository on GitHub:
- Log in to your GitHub account.
- Click the “+” icon in the top right corner and select “New repository.”
- Name the repository, choose if it’s public or private, and click “Create repository.”
3. Commit
What is a Commit?
A commit is a saved change in Git. Think of it like taking a snapshot of your project at a specific time. Each commit has a unique ID and a message that describes what changes were made.
- Example: If you update the code for your website, you can commit those changes with a message like “Updated homepage layout.”
Practical Concept:
- To make a commit in Git:
- First, stage your changes:
git add filename
- Then, commit the changes:
git commit -m "Your commit message here"
- First, stage your changes:
4. Branching
What is Branching?
Branching is a way to create a separate path in your project to work on new features or fix bugs without changing the main code. The main branch is usually called “main” or “master,” and new branches are created from this main branch.
- Example: You create a new branch called “feature-1” to add a new feature to your project without affecting the main project.
Practical Concept:
- To create a branch:
- Use the command:
git branch branch-name
- Use the command:
- To switch to the branch:
- Use the command:
git checkout branch-name
- Use the command:
5. Remote
What is a Remote in Git Terminology?
A remote is a link to a version of your project hosted somewhere else, like GitHub. It allows you to push and pull changes between your local computer and GitHub.
- Example: When you upload your project to GitHub, your Git repository has a remote link pointing to GitHub. The default remote name is usually “origin.”
Practical Concept:
- To view the remote URL for your project:
- Use the command:
git remote -v
- Use the command:
6. GitHub Flow
What is GitHub Flow?
GitHub Flow is a simple workflow that helps developers work together more efficiently. It’s a step-by-step process used on GitHub to create, review, and merge code changes.
Steps in GitHub Flow:
- Create a Branch: Start by creating a branch from the main branch.
- Make Commits: Work on your changes and commit them.
- Open a Pull Request (PR): When your work is ready, open a pull request to let others know.
- Review and Discuss: Team members review your changes and suggest improvements.
- Merge the PR: Once approved, merge your changes into the main branch.
- Deploy: Deploy the changes, if applicable.
Summary Table
Concept | Description | Commands/Actions |
---|---|---|
Version Control | Tracks changes over time. | N/A |
Distributed VC | Each user has a complete project history. | N/A |
Git | A software for version control. | git init , git add , git commit , etc. |
GitHub | A platform for sharing Git projects online. | Create repository, share link, open pull requests. |
Repository | A storage space for a project. | Create repository, clone, git init . |
Commit | A saved change in Git. | git add , git commit -m "message" |
Branching | Create separate paths for working on new features. | git branch branch-name , git checkout branch-name |
Remote | A link to a project hosted online, like GitHub. | git remote add origin URL , git push |
GitHub Flow | A workflow for collaboration on GitHub. | Create branch, make commits, open pull request, merge, deploy. |
2. GitHub Entities
1. Accounts
Accounts in GitHub are like different “users” or “workspaces” where work is managed. There are three types of accounts:
- Personal Account:
- This is for individuals.
- You can have personal repositories (projects).
- Example: A software developer has their own account to store their personal projects.
- Organization Account:
- Used by companies or groups.
- Helps manage projects across teams.
- Example: A software company creates an organization account to store all company projects, with each team having access.
- Enterprise Account:
- For large companies needing more control, security, and features.
- Best for organizations that need advanced management and security features.
- Example: A global company with many teams and strict data control uses an enterprise account.
2. Products
GitHub offers different products based on the type of account:
- For Personal Accounts:
- Free: Basic features, unlimited public and private repositories, limited to basic actions.
- Pro: Extra features like more storage, better tools, and increased GitHub Actions minutes (automation).
- For Organizations:
- Free: Limited features, but good for small teams.
- Teams: Has more advanced features like better team management, more automation, and permissions.
3. Deployment Options for GitHub Enterprise
GitHub Enterprise offers flexible deployment options for companies to ensure security and customization:
- Enterprise Cloud:
- Hosted on GitHub’s cloud.
- No need to manage the hardware.
- Example: A remote team works on GitHub’s cloud to avoid managing servers.
- Enterprise Server:
- Hosted on the company’s servers.
- Better for companies with strict data control needs.
- Example: A bank might use this option to keep data secure on its own network.
- Enterprise Managed Users:
- Offers managed user accounts and data control for security.
- Example: A large corporation that needs to manage user permissions centrally.
User Profile Features
Profiles help show information about users or organizations. These are the main features:
- Metadata: Basic information like username, bio, location, and website link.
- Achievements: Badges that show user contributions and milestones.
- Profile README: A personal README file that introduces the user or organization.
- Example: You can write about your skills and projects in this README file.
- Repositories: Places where code is stored. Users and organizations can have multiple repositories.
- Example: A user creates a repository to store their code for a project.
- Pinned Repositories: Specific repositories you choose to highlight on your profile.
- Example: Pin a project you are proud of to display it at the top of your profile.
- Stars: A way to show appreciation for a repository.
- Example: If you like someone’s project, you can “star” it to bookmark it.
3. GitHub Markdown
1. What is Markdown?
Markdown is a simple way to style text on the web. It is used in GitHub to format text in places like issues, pull requests, and README files. Markdown is easy to learn and helps make your text look more organized and attractive.
Key Benefits of Markdown:
- Easy to read and write.
- Works well for simple styling like headings, lists, links, and tables.
- Markdown files end with
.md
(e.g.,README.md
).
2. Text Formatting Toolbar
In GitHub, there is a Text Formatting Toolbar to help you add Markdown styling without needing to remember all the syntax.
Where to Find It:
The Text Formatting Toolbar is found above the text box in places like:
- Issue comments: When discussing a problem.
- Pull request comments: When reviewing code changes.
The toolbar includes options like Bold, Italic, Headers, Lists, and Links. You can click on these to quickly apply formatting to your text.
3. Basic Formatting Syntax
Let’s go over some basic Markdown syntax you’ll need for GitHub.
3.1 Headings
Headings help structure your text by creating titles and subtitles. They range from level 1 (largest) to level 6 (smallest).
-
Syntax: Use
#
for headings. The more#
, the smaller the heading.1 2 3
## Heading 1 ### Heading 2 #### Heading 3
3.2 Links
You can add links to guide readers to other pages or websites.
-
Syntax:
[Link Text](URL)
Example:
1
[Visit GitHub](https://github.com)
3.3 Task Lists
Task lists are useful in tracking items that need to be completed. You often see these in issues or project boards.
-
Syntax: Use
- [ ]
for an unchecked item and- [x]
for a checked item.Example:
1 2
- [x] Task 1 - [ ] Task 2
3.4 Comments
Comments help you add notes that won’t appear in the formatted document. They’re handy for leaving reminders or descriptions for yourself or your team.
-
Syntax:
<!-- Comment -->
Example:
1
<!-- This is a comment that won't appear in the output -->
4. Slash Commands
Slash Commands are shortcuts you can type to quickly trigger an action in GitHub. They’re mainly used in issues and pull requests.
Where to Use Slash Commands:
- In issue comments and pull request comments.
Common Slash Commands
Here are some useful slash commands:
/assign @username
: Assigns an issue or pull request to a user./label bug
: Adds a specific label likebug
to categorize the issue or pull request./close
: Closes an issue or pull request.
How to Use Slash Commands:
Type the /
symbol, followed by the command and the necessary details, in the comment box.
Example:
1
2
3
/assign @exampleuser
/label enhancement
/close
Practical Example
Tasks
- Set up the repository
- Write initial documentation
- Implement feature X
Links
Assignees
/assign @team_member ```
4. GitHub Desktop
1. Difference Between GitHub Desktop and github.com
GitHub Desktop is a desktop application that allows users to manage their GitHub repositories locally on their computers. In contrast, github.com is the web platform for hosting and managing repositories online.
Key Differences:
- Interface:
- GitHub Desktop provides a graphical user interface for managing repositories, while github.com offers a web-based interface.
- Functionality:
- GitHub Desktop is primarily used for local repository management, allowing users to commit changes, manage branches, and sync with the online repository easily.
- github.com is used for collaborating with others, accessing issues, pull requests, and project management tools.
- Offline Access:
- GitHub Desktop allows users to work offline on their local repositories.
- github.com requires an internet connection to access repositories and make changes.
5. GitHub Mobile
1. Features Available with GitHub Mobile
GitHub Mobile is an application that allows users to access and manage their GitHub repositories on mobile devices. It offers several features to help users stay connected and productive on the go.
Key Features:
- View Repositories:
- Access all your repositories and browse their contents directly from your mobile device.
- Manage Issues:
- Create, edit, and comment on issues to keep track of tasks and bugs while away from your computer.
- Pull Requests:
- Review and merge pull requests easily, allowing for quick collaboration with team members.
- Notifications:
- Stay updated with notifications for issues, pull requests, and comments, helping you keep track of project activity.
- Search Functionality:
- Use the search feature to find repositories, issues, and pull requests quickly.
2. Managing Notifications Through GitHub Mobile
GitHub Mobile allows users to manage their notifications efficiently, ensuring you never miss important updates.
Notification Management Features:
- Real-Time Notifications:
- Receive notifications in real-time for any updates on issues, pull requests, and comments.
- Filter Notifications:
- Filter notifications by type (e.g., mentions, comments, or assigned issues) to focus on what matters most.
- Mark as Read:
- Easily mark notifications as read or unread to keep track of which ones require your attention.
- Actionable Notifications:
- Take immediate action on notifications, such as replying to comments or closing issues, directly from the app.
- Settings:
- Customize notification settings to control how and when you receive alerts, ensuring you stay in control of your workflow.
2. Features Available with GitHub Desktop
GitHub Desktop comes with various features to simplify the workflow of managing Git repositories.
1. Simple Interface
- Easy-to-use interface for managing your repositories, branches, and commits without needing command line tools.
2. Branch Management
- Create, switch, and manage branches effortlessly, helping to organize your work and collaborate on features.
3. Commit Changes
- Stage and commit changes to your local repository directly from the application, with an option to add commit messages.
4. Syncing
- Push and pull changes to and from github.com easily, keeping your local and remote repositories in sync.
5. Conflict Resolution
- A built-in tool to help resolve merge conflicts, making collaboration smoother.
6. Repository Cloning
- Clone repositories directly from github.com to your local machine with just a few clicks.
7. Open in Command Line
- Option to open your repository in your preferred command line tool for advanced Git operations.
Like, Share & Subscribe Now
-
Joining takes one minute and is beneficial for your career: Subscribe Now
-
Yatri Blog: Read Now
-
Let’s build a community together: Visit us
Follow our Creators
Join Our Exclusive Community
Follow us on Social Media
-
Twitter: Follow Now
-
Instagram: Follow Now
-
WhatsApp Channel: Follow Now