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
git clone <repository-url>
git init
: Initializes a new Git repository.git add
: Adds changes to the staging area.git commit
: Commits changes to the repository.git push
: Pushes changes to the remote repository on GitHub.git pull
: Pulls changes from the remote repository on GitHub.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.
GitHub allows you to collaborate with others on your code by creating pull requests, reviewing code, and merging changes.
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:
HEAD
: A file that points to the current branch or commit.objects
: A directory that contains all of the Git objects (commits, trees, and blobs)
that make up your repository.refs
: A directory that contains references to commits, branches, and tags.config
: A file that contains the configuration settings for your repository.hooks
: A directory that contains scripts that can be run before or after certain Git
commands.index
: A file that contains the current state of the staging area.logs
: A directory that contains logs of all Git activity in your repository.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 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:
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.
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
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
:
--oneline
: Shows each commit on a single line with the commit hash and message.
--graph
: Shows a graph of the commit history with branches and merges.--author
: Filters the commit history by author.--since
: Filters the commit history by date.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 checkout <branch>
: Switches to the specified branch.git checkout -b <new-branch>
: Creates a new branch and switches to it.git checkout <commit>
: Checks out the specified commit, detaching the HEAD
from
any branch.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
:
git status
: Shows the status of the current repository.git status -s
: Shows a short summary of the status with abbreviated status codes.
git status --ignored
: Shows ignored files in addition to the regular status.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.