added a section on branches to git.md

This commit is contained in:
scbj
2024-11-25 11:14:12 +01:00
parent 85d836b926
commit 7569eb1801

23
git.md
View File

@@ -2,10 +2,29 @@
## Table of contents
- [git submodule](#git-submodule)
- [branches](#branches)
- [create a branch](#create-a-branch)
- [submodules](#submodules)
## git submodule
## branches
### create a branch
To create a branch use subcommand `branch` or `checkout` with flag `-b`:
```bash
# create new branch ('base-branch' is optional)
git branch <branch-name> <base-branch>
git checkout -b <branch-name> <base-branch>
# switch branch ('checkout -b' combines the 'branch' and 'switch' subcommands)
git switch <branch-name>
```
## submodules
To fetch submodules of a cloned repository use:
```bash
# do it manually
git submodule init