Git Terminology
Git is a tool that comes with a lot of terminology and jargon, which can be challenging for beginners or those familiar with the basics but aiming to become experts. Let's explore some of the commonly used terms.
Some commonly used terms are:
Branch
A branch is a version of the repository that splits off from the main project. It's a key feature in most modern version control systems. In a Git project, you can have multiple branches and perform various operations on them, such as renaming, listing, or deleting.
Checkout
In Git, the term "checkout" refers to switching between different versions of a target entity, and the 'git checkout' command is specifically used to switch between branches within a repository.
Cherry-Picking
Cherry-picking in Git allows you to apply a specific commit from one branch to another. If you accidentally commit a change to the wrong branch and don't want to merge the entire branch, you can revert the commit and then cherry-pick it onto the correct branch.
Clone
The 'git clone' command-line utility in Git is used to create a copy of a target repository. If you want a local copy of your repository from GitHub, this tool lets you clone the repository from the URL to your local directory.
Fetch
It is used to fetch branches and tags from one or more repositories, along with the necessary objects to complete their histories, and it updates the remote-tracking branches.
HEAD
HEAD represents the most recent commit in the currently checked-out branch. You can think of HEAD as a reference to the current branch. When you switch branches using `git checkout`, the HEAD revision changes to point to the new branch.
Index
The Git index is a staging area between the working directory and the repository, used to accumulate a set of changes that you want to commit together.
Master
"Master" is a naming convention for the default branch in Git. When you clone a project from a remote server, the resulting local repository initially contains only one branch, which is named "master." This signifies that "master" is the repository's default branch.
Merge
Merging is the process of combining a forked history into a unified branch. The 'git merge' command allows you to integrate changes from different branches into a single branch.
Origin
In Git, "origin" is a reference to the remote repository from which a project was initially cloned. It simplifies referencing by replacing the original repository URL with a more convenient name.
Pull/Pull Request
The term "pull" refers to receiving data from GitHub by fetching and merging changes from the remote server into your working directory. The 'git pull' command is used to perform this action.
Pull requests are a process through which a developer notifies team members that a feature is complete. Once the feature branch is ready, the developer submits a pull request through their remote server account, alerting the team to review and merge the code into the master branch.
Push
The term "push" refers to uploading content from a local repository to a remote repository. Pushing transfers commits from your local repository to the remote one and can overwrite changes, so caution is needed when performing this action.
Rebase
In Git, "rebase" refers to the process of moving or combining a sequence of commits onto a new base commit. Rebasing is particularly useful and can be visualized effectively within a feature branching workflow.
From a content perspective, rebasing is a technique for changing the base of your branch from one commit to another.
Remote
In Git, the term "remote" refers to a shared repository that team members use to exchange changes. This remote repository is hosted on a code hosting service such as an internal server, GitHub, or others.
In the case of a local repository, a remote typically does not provide a file tree of the project's current state; instead, it contains only the '.git' versioning data.
Repository
In Git, a repository acts as a data structure used by version control systems to store metadata for a collection of files and directories. It contains both the files themselves and the history of changes made to them, essentially serving as your project's folder. Each repository is dedicated to a specific project and contains all the relevant project data.
Stashing
If you're in the middle of working on something but need to switch branches without committing your incomplete work, you can use the 'git stash' command. This allows you to save your changes temporarily and switch branches without committing anything unfinishedunfinished.
Tag
Tags serve as markers for specific points in a Git project's history, often highlighting important commits. They are typically used to label significant stages, like version releases (e.g., v1.1), for future reference. There are two types of tags in Git.
- Light-weighted tag
- Annotated tag
Upstream And Downstream
"While 'upstream' typically refers to the source from which you cloned a repository and 'downstream' refers to any project that incorporates your contributions, these terms can also apply to other contexts beyond Git repositories."
Git Revert
In Git, the term "revert" refers to the process of undoing changes made by a commit using the 'git revert' command, which creates a new commit that undoes the effects of the specified commit, rather than simply undoing the commit itself.
Git Reset
In Git, the term "reset" refers to undoing changes, and the 'git reset' command is used to accomplish this. The command has three primary forms of invocation.
- Soft
- Mixed
- Hard
Git Ignore
In Git, the term "ignore" refers to intentionally untracked files that Git should not track, and it does not impact files that are already being tracked by Git.
Git Diff
The 'git diff' command is a versatile utility that compares changes between various Git data sources, such as files, branches, and commits, and displays differences between commits, or between a commit and the working tree.
Git Cheat Sheet
A Git cheat sheet is a concise reference guide that provides basic Git commands and installation instructions, designed for quick and easy access without requiring prior knowledge.
Git Flow
GitFlow is a branching model for Git, created by Vincent Driessen. It provides a well-structured approach to collaboration and scaling development teams, simplifying many repository operations into single commands.
Git Squash
In Git, "squash" refers to combining multiple previous commits into a single one. Git squash is a useful technique for grouping related changes before sharing them with others, and it can be done effectively using the powerful interactive rebase command.
Git Rm
The 'git rm' command is used to remove tracked files from the Git index and can also be used to delete files from both the working directory and the staging index.
Git Fork
A fork is a duplicate of a repository, enabling you to experiment and troubleshoot changes without impacting the original project.
Forks are excellent for suggesting bug fixes. To address an issue you've identified, you can:
- Fork the repository.
- Make the fix.
- Submit a pull request to the project owner.