Site icon JnPnote

[Learning Git] Branching

This is my personal study note for remembering and reviewing what I learned about Git.

Commands
git branch: To list all the branch of git project
git branch branch_name: To create new branch
git checkout branch_name: To switch to the branch_name
git checkout -b branch_name: To create new branch and switch to the branch_name at the same time
git checkout -b branch_name1 branch_name2: To create new branch and switch to the branch_name1 and also set it to track branch_name2.
git merge branch_name: To merge branch_name into current branch
git branch -d branch_name: To delete the branch_name
git rebase branch_name: To move current branch down to the branch_name (nicer linear sequence of commits)
git branch -u branch_name1 branch_name2: To set the branch_name2 to track branch_name1. If branch_name2 is already checked out, leave it off.

git merge

git rebase

I am studying these from the web https://www.codecademy.com/learn/learn-git with seven days free trial, and https://learngitbranching.js.org/ which is totally free to learn.

Exit mobile version