Git Branching:
Git branching can be defined as a feature of the Git version control system that allows developers to create parallel lines of development within a single repository.
In simpler terms, it's like having multiple versions of your project running simultaneously. Each branch has its own set of changes, edits, and experiments, while still being connected to the main project. This enables developers to work on different features or fixes separately without interfering with each other's work.
It is like managing different parts of a tree to work on different aspects of your project, keeping things organized and allowing for parallel development without causing chaos in the main part of your project.
Why do we need Git branching?
It helps teams work together better by making sure everyone knows what they're doing and can do their part without causing problems for others.
It guides changes from development to production.
It Keeps the code clean and fixes issues quickly without causing problems in the development process.
Commands:
To check the current branch -
git branch
To create a branch -
git branch <name-of-new-branch>
To delete a branch -
git branch -D <branch_name>
To switch to a new branch -
git checkout <branch-name>
to switch and create a branch at the same time -
git checkout -b <branch-name>
To list all branches -
git branch -a
Git Revert and Reset
In git, revert means some change. It is used for commands to undo changes to a repository's commit history. It's like hitting the "undo" button for a specific commit, allowing you to revert unwanted changes without altering the commit history. This is useful when you want to keep a record of the original commit but undo its effects.
To revert a commit to a previous version : git revert <comit-id>
Git reset is like going back in time to a specific point. It moves your project's timeline back to a certain moment in time. Depending on how you use it, it can either keep your recent changes around for you to work on, or it can wipe them out completely and take you back to that point in time as if those changes never happened.
Git Rebase and Merge
What Is Git Rebase?
Git rebase is a command used to reapply commits on top of another branch's commit history. It moves effectively the entire branch to begin from a different point in the commit history, resulting in a linear sequence of commits. This process is often used to integrate changes from one branch into another while maintaining a clean and linear history.
What Is Git Merge?
Git merge is a command used to integrate changes from one branch into another branch. It combines the changes made in the source branch with the target branch, creating a single unified branch that combines the changes from both. This process allows developers to bring together their work and collaborate effectively on a common codebase.
git merge
: It is a command used to merge the two branches.
Summary:
In this blog, we covered the topic related to git branching which allows for parallel development, Git revert and reset provide ways to manage changes in the commit history, Git rebase helps streamline development workflows, and Git merge facilitates collaboration and integration of changes between branches.