Git Regular Workflow – Work With Branches
The goal of this section is to help you understand how to manage branches, which is one of the most critical concepts of Git operations.
In this section, we'll cover six key git commands.
git branch
: this command is a multi-use command. For example, it is used for creating a new branch, checking branch status, and deleting an unused branch.git checkout
: with this command, you can switch your current branch to a selected branch.git switch
: with this command, you can get the same result as withgit checkout
. It is a newly introduced command used as a substitute for thegit checkout
command.git merge
: with this command, you can merge branches. The merge operation can be done through a Remote Repository on the GitHub website. The merge operation on GitHub will be explained in the next chapter.git rebase
: with this command, you can reapply commits on top of another base branch. This command is useful when you want to streamline the commits diverged into multiple branches. The rebase operation can also be done through a Remote Repository on the GitHub website. This is an option of the merge feature of GitHub.git stash
: with this command, you can separately manage WIP (Work In Progress) codes. When you want to switch the current branch in the middle of editing the Working Tree, the edits may prevent you from switching the current branch. In that case, this command is useful. The stashed lines of code are parked somewhere temporarily.