added a section on branches to git.md
This commit is contained in:
25
git.md
25
git.md
@@ -2,10 +2,29 @@
|
|||||||
|
|
||||||
## Table of contents
|
## 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
|
```bash
|
||||||
# do it manually
|
# do it manually
|
||||||
git submodule init
|
git submodule init
|
||||||
@@ -16,4 +35,4 @@ git clone --recurse-submodules
|
|||||||
|
|
||||||
# if repo is already cloned
|
# if repo is already cloned
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user