# Git Branch¶

## Branch Name Contain The ‘space’ Char¶

I do not know if you are going to find a pure, technical reason down at the bottom of this. However, I can offer that spaces tend to throw wrenches in all sorts of *nix utilities and filename processing, so it may have been to avoid accidentally doing anything wrong further down the line. After all, a git branch boils down to a file in the repo and this avoids dealing with spaces in that file’s name (specifically, a branch is a file in .git/refs/heads/, as mentioned in the comment).

Mostly I would guess the reason is philosophical, and meant to keep things simple. Branch names are human-readable names that have no real reason to be complicated (and require typing two extra chars each time haha, to invoke the ghost of the sysadmin who has aliased every command to an indecipherable three letter combination). Otherwise known as the “why cd is not chdir” argument.

https://stackoverflow.com/a/6619113/12539782

## Create Empty Branch Locally And Remotely¶

# local
git checkout --orphan empty-branch
git rm -rf .
# remote
git commit --allow-empty -m "root commit"
git push origin empty-branch


https://stackoverflow.com/a/34100189/12539782

## Delete A Git Branch Both Locally And Remotely¶

# delete branch locally
git branch -d localBranchName

# delete branch remotely
git push origin --delete remoteBranchName # Delete Remote Branch In Local Git Env


## Git Clone Specify Branch¶

git clone --branch <branchname> <remote-repo-url>


## Remove Tracking Branches No Longer On Remote¶

$git branch -a * main remotes/origin/articles-main remotes/origin/gh-pages remotes/origin/main # remote branch articles-main, gh-pages has been deleted$ git remote prune origin
Pruning origin
URL: [email protected]:tianheg/wiki.git

* [pruned] origin/articles-main
* [pruned] origin/gh-pages