Git is a widely used version control system (VCS) that allows developers to track changes in their source code during software development. It facilitates collaboration among multiple developers by enabling them to work on different parts of a project simultaneously without interfering with each other’s work. Git was created by Linus Torvalds in 2005 for the development of the Linux kernel, and it has since become the de facto standard for version control in the software industry.
- Repository (Repo): A repository is a directory or storage space where your project files and their revision history are stored. Repositories can be local (on your machine) or remote (on a server like GitHub, GitLab, or Bitbucket).
- Commit: A commit is a snapshot of your repository at a specific point in time. Each commit has a unique ID and contains the changes made to the files, along with a commit message describing what was done.
- Branch: A branch is a separate line of development in your repository. The main branch is usually called master or main, but you can create and work on other branches independently. Branches allow multiple features or bug fixes to be developed in parallel.
- Merge: Merging is the process of integrating changes from one branch into another. This is typically done after a feature or bug fix has been completed and tested on a separate branch.
- Clone: Cloning a repository means creating a copy of a remote repository on your local machine. This allows you to work on the project locally.
- Pull: Pulling means fetching changes from a remote repository and merging them into your local repository. This keeps your local repository up-to-date with the latest changes.
- Push: Pushing means sending your local changes to a remote repository. This updates the remote repository with your commits.
Here’s a typical workflow when using Git:
- Clone the Repository:
- Create a New Branch:
- Make Changes and Commit:
- Push Changes to Remote Repository:
- Create a Pull Request: After pushing your changes, you typically create a pull request (PR) on the remote repository’s hosting service (e.g., GitHub) to review and merge your changes into the main branch.