Branching Flashcards
What is Git Branching
Diverge from the main line of development and continue to do work without messing with that mainline
How to create Local Branch
git branch branch-name
eg: git branch Testing-branch
How to check on which branch currently working
by using a special pointer called Header - to points to the current checkout branch.
git log –oneline –decorate – graph –all
How to check what are the branches created
git branch -> display local branches
git branch -r -> remote branches
git branch -a -> display both remote and local
branches
How to checkout to the particular branch
git checkout branch-name
eg: git checkout Testing-branch
How to checkout to the particular branch in version 2.23
git switch branch-name
eg: git switch Testing-branch
How to create and checkout in one line
git checkout -b branch-name git checkout -b Testing-branch-two or git switch -c branch-name git switch -c Testing-branch-two
Note: both -b and -c are used to create a new branch
How to check branches merged
git branch –merged
How to check the unmerged branch
git branch –no-merged
How to check the last commit on each branch
git branch -v
How to delete the branch
git branch -d branch-name
git push remote –delete branch-name
How to delete the branch forcibly
git branch -D
How to change the branch name -Local
git branch –move
How to change the branch name remotely
Step1: git branch –move
Step2: git push –set-upstream origin
Step3: git push origin –delete
Is it a good idea to change the name of the branch master
Changing the name of a branch like master/main/mainline/default will break the
integrations, services, helper utilities and build/release scripts that your repository
uses.