【Git】How to remove branches and tags

Sponsored Link

How to remove a local branch, remote branch, or tag.
I forget how to do it every time, so I output it.

Pull remote branch to local branch

List of local branches

$ git branch
* master
dev

List of remote branches

$ git branch -r
origin/HEAD -> origin/master
origin/test

Modernize local remote branches

$ git fetch

Pull remote branch differences to local branch

$ git pull origin <REMOTE-BRANCH-NAME>: <LOCAL-BRANCH-NAME> </REMOTE-BRANCH-NAME>

Delete a local branch

$ git branch --delete <LOCAL-BRANCH-NAME>

Remove a remote tag

$ git tag -d <TAG-NAME>
$ git push --delete origin <TAG-NAME> </TAG-NAME>

Delete a remote branch

$ git branch -d <REMOTE-BRANCH-NAME>
$ git push --delete origin <REMOTE-BRANCH-NAME> </REMOTE-BRANCH-NAME>

Add: Bring a remote branch locally

$ git checkout -b dev origin/dev

* dev is the name of the local branch. origin/dev is the name of the remote branch.

Copied title and URL