![]() |
VOOZH | about |
Git is a distributed version control system (VCS) used to track changes in source code during software development. It helps developers collaborate, manage different versions of code, and roll back to previous states if needed.
Before using Git, it is important to understand some of its core concepts. These concepts will help you get started and make it easier to work with Git in real-world scenarios.
A repository (or repo) is a storage space where your project files and their history are kept. There are two types of repositories in Git:
A commit is a snapshot of your project at a specific point in time. Each commit has a unique identifier (hash) and includes a message describing the changes made. Commits allow you to track and review the history of your project.
Branches allow developers to work on separate tasks without affecting the main codebase. Common branch types include:
Merging is the process of integrating changes from one branch into another. It allows you to combine the work done in different branches and resolve any conflicts that arise.
Cloning a repository means creating a local copy of a remote repository. This copy includes all files, branches, and commit history.
In Git, your files can be in one of three main states. Understanding this is key to understanding how Git works:
This three-step process (modify -> add -> commit) gives you precise control over what gets saved in your project's history.
Git commands are important for navigating and controlling your project repository. These commands help you manage files, track changes, and collaborate with others.
| Command | Description |
|---|---|
| git status | Shows the current status of the repository — staged, unstaged, and untracked files. |
| git add <file-name> | Stages a specific file for commit. Use git add . to stage all changes. |
| git commit -m "message" | Commits the staged changes with a descriptive commit message. |
| git branch <branch-name> | Creates a new branch with the given name. |
| git checkout <branch-name> | Switches to the specified branch. |
| git merge <branch-name> | Merges changes from the given branch into the current branch. |
| git push origin <branch-name> | Pushes the local branch changes to the remote repository. |
| git pull origin <branch-name> | Fetches and merges changes from the remote repository into the local branch. |
| git log | Displays the commit history for the current branch. |
Git workflows define how developers should use Git in a structured and efficient manner.
git clone git@github.com:username/repository.git
git checkout -b feature-branch
git add <file-name>
git commit -m "Add new feature"
git push origin feature-branch
After pushing your changes, create a pull request on GitHub to merge the feature branch into the main branch.
git checkout main
git pull origin main
git branch -d feature-branch
git push origin --delete feature-branch
Git is a crucial tool for modern software development and DevOps. Mastering Git setting up repos, using branches, and managing code enables efficient collaboration and a streamlined, scalable workflow.
Git Hosting stores your Git repositories on a remote server, enabling collaboration, backup, pull requests, CI/CD, and even website hosting, while Git manages changes locally.
GitHub is a cloud-based Git hosting platform owned by Microsoft, popular for open-source projects and beginner developers. It provides a complete environment for version control, collaboration, and deployment.
GitLab is a complete DevOps platform offering Git repository hosting along with built-in CI/CD, issue tracking, and project management tools. It is ideal for teams and enterprises looking to automate workflows and manage code efficiently.
Bitbucket is a Git hosting platform by Atlassian, designed for private repositories and team collaboration. It is ideal for small teams or companies seeking a secure environment with tight integration to project management tools.