bookmark_borderCreate, delete, and list git branch

Create a branch

(master) $ git branch branch_one
(master) $ git checkout branch_one
Switched to branch 'branch_one'
(branch_one) $
  • the branch name is branch_one

Edit code and push the remote branch

(branch_one) $ git add . && git commit -m "branch test"
[b_one 1b3fb2e] branch test
 1 file changed, 3 insertions(+), 1 deletion(-)
(branch_one) $ git push origin b_one

Now you can pull requests to master.

Delete the branch

(master) $ git branch -d branch_one
error: The branch 'branch_one' is not fully merged.
If you are sure you want to delete it, run 'git branch -D branch_one'.
  • If you want to delete the branch, the branch should be merged.
(master) $ git branch -D branch_one
Deleted branch branch_one (was 66a559f).
(master) $ git push origin --delete branch_one
To https://github.com/xxxxx/xxxx-xxxx-xxxx.git
 - [deleted]         branch_one

List of branches

(branch_one) $ git branch -a
  =
* branch_one
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/branch_one
  remotes/origin/master
ANOTE.DEV