Git – Some commonly used commands

Xóa branch local

Use one 2 command:

git branch -d branch_name
git branch -D branch_name

The -d option stands for –delete, will remove branches, only when you push it with the remote and branch merger (on the server). your.

-D option stands –delete –force, delete the branch whether push and merger states are done or not, so be careful when using this!

Replaced the entire branch2 into branch1

Sometimes you split a branch and grow it after a while, the difference was too much, you want to completely replace the new branch (branch2) for the old branch (branch1).

git checkout branch2
git merge -s ours branch1
git checkout branch1
git merge branch2