Git creates a branch and pushes it to a remote branch


Now I am working on the master branch. The goal is clean, and there is no need tocommitOf:

$ git branch
* master

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

New remote branch

Create a new local branch:

$ git checkout -b dbg_lichen_star

Check the current branch status:

$ git branch
* dbg_lichen_star

An asterisk (*) indicates the current branch. The current state is that the new branch has been successfully created and has been switched to the new branch.

Push the new local branch to the remote server. The remote branch has the same name as the local branch (of course, it can be named at will):

$ git push origin dbg_lichen_star:dbg_lichen_star

usegit branch -aView all branches and you will seeremotes/origin/dbg_lichen_starThis remote branch indicates that the new remote branch is successful.

Delete remote branch

I prefer the simple method of pushing an empty branch to a remote branch, which is actually equivalent to deleting the remote branch:

$ git push origin :dbg_lichen_star

You can also use:

$ git push origin --delete dbg_lichen_star

Both methods can delete the specified remote branch