Git Branching Strategies
Introduction to git branching strategies
In one of the products we've worked on, we used ‘git’ for version controlling with GitLab as our hosting provider. In this article, we're going to discuss hands-on on git as well as the git branching strategies we follow. Along with recommendations on how to use git to accomplish work in a consistent and productive manner.
git clone <remote origin="" url=""></remote>
To create a copy of a git repository from the remote source to your local also set the remote to the original source so that you can pull/push on the same repository.
git checkout -b <branch_name></branch_name>
To create a new branch from an existing branch with preserve the uncommitted/stash changes.
To check all the branch's revisions in your local system also helps in finding out which branch is currently active.
git add -p
To add content from the working directory into the staging area (or “index”) for the next, commit.
git commit -m <commit message=""></commit>
Create a new commit containing the current contents of the index and the given log message describing the changes
git push origin <branch name=""></branch>
To publish locally committed changes to origin.
git pull origin <branch name=""></branch>
To fetch & merge changes from origin to your local branch.
To record the current state of the working directory and the index, but want to go back to a clean working directory.
git stash list
To list all the recorded index of the working directory/repository.
git stash pop
It does the same but leaves it in the stash stack.
git stash apply
To apply the top stashed element to your current working branch/directory and remove it from the stack
To view commit history with SHA for current active branch
git reset — hard <commit sha="" branch="" name=""></commit>
To reset the active branch head to a particular commit or branch.
Git Branching Strategies
Do’s and Don’ts
To sum it up
We hope this article will helps you use git in a more productive manner. Another tool that boosts productivity are chatbots. Get started with an Engati Chatbot today!
We will also soon be publishing it on GeeksforGeeks.
Engage and retain your customers using Engati. Try it for free!Set it up in 7 mins!
Engati powers 45,000+ chatbot & live chat solutions in 50+ languages across the world.
We aim to empower you to create the best customer experiences you could imagine.
So, are you ready to create unbelievably smooth experiences?