Git and GitHub Tutorial

Git Icon

Introduction

Git is a version control system that allows you to track changes to your code over time. GitHub is a
web-based platform that provides hosting for Git repositories and allows you to collaborate with others
on your code.

git help

Getting Started

  1. Install Git on your computer.
  2. Create a GitHub account.
  3. Create a new repository on GitHub.
  4. Clone the repository to your local machine using the command line.
git clone <repository-url>

Basic Commands

Branching and Merging

Git allows you to create branches to work on new features or bug fixes without affecting the main codebase. You can then merge your changes back into the main branch when you're ready.

Collaboration

GitHub allows you to collaborate with others on your code by creating pull requests, reviewing code, and merging changes.

Lets look inside the .git folder

Inside the .git Folder

The `.git` folder is a hidden folder that is created when you initialize a Git repository in a directory. It contains all of the information and metadata that Git uses to manage your repository, including the commit history, branches, tags, and configuration settings.

Here's a brief overview of some of the files and directories you might find inside the `.git` folder:

It's generally not recommended to modify the contents of the `.git` folder directly, as this can cause issues with your repository. Instead, you should use Git commands to manage your repository.

GitLab

GitLab is a web-based Git repository manager that provides source code management, continuous integration, and other features for software development teams.

Here are some key features of GitLab:

  • Git repository management with support for Git LFS (Large File Storage).
  • Continuous integration and continuous deployment (CI/CD) pipelines.
  • Issue tracking and project management tools.
  • Wiki and documentation support.
  • Code review and collaboration tools.
  • Integration with other tools and services, such as Slack and Jira.

GitLab is available in both a cloud-hosted version and a self-hosted version that you can install on your own servers. The self-hosted version is open source and free to use, while the cloud-hosted version offers additional features and support for a fee.

GitLab logo

Extra Stuff on adi's bucket list

15 tips for more advance members to read into
gitleaks or git secrets

Git Bisect

git bisect is a command in Git that allows you to perform a binary search through the commit history of a repository to find the commit that introduced a bug or regression.

The command works by allowing you to mark a known "good" commit and a known "bad" commit, and then automatically checking out a middle commit between the two for you to test. Based on your testing, you can then mark the commit as either "good" or "bad", and git bisect will continue to check out middle commits until it finds the commit that introduced the bug.

git bisect is a powerful tool for debugging and finding regressions in your code. It can save you a lot of time and effort compared to manually searching through the commit history.

Git Log

git log is a command in Git that shows the commit history of the current repository. By default, it shows the commit hash, author, date, and commit message for each commit in reverse chronological order (i.e., newest commits first).

Here are some common options for git log:

Git Checkout

git checkout is a command in Git that allows you to switch to a different branch or commit. It can also be used to create a new branch.

Here are some common use cases for git checkout:

Git Status

git status is a command in Git that shows the status of the current repository. It shows which files have been modified, which files are staged for commit, and which files are untracked.

Here are some common use cases for git status:

Conclusion

Git and GitHub are powerful tools for managing your code and collaborating with others. With a basic understanding of Git and GitHub, you can start using these tools to improve your workflow and productivity.