2019-08-19 13:44:48 +01:00
|
|
|
# git switch
|
|
|
|
|
|
|
|
> Switch between git branches. Requires git version 2.23+.
|
|
|
|
> See also `git checkout`.
|
|
|
|
> More information: <https://git-scm.com/docs/git-switch/>.
|
|
|
|
|
|
|
|
- Switch to an existing branch:
|
|
|
|
|
|
|
|
`git switch {{branch_name}}`
|
|
|
|
|
|
|
|
- Create a new branch and switch to it:
|
|
|
|
|
|
|
|
`git switch --create {{branch_name}}`
|
|
|
|
|
2019-08-21 12:44:22 +01:00
|
|
|
- Create a new branch based on an existing commit and switch to it:
|
2019-08-19 13:44:48 +01:00
|
|
|
|
|
|
|
`git switch --create {{branch_name}} {{commit}}`
|
|
|
|
|
2020-01-23 10:27:19 +00:00
|
|
|
- Switch to the previous branch:
|
|
|
|
|
|
|
|
`git switch -`
|
|
|
|
|
2019-08-21 12:44:22 +01:00
|
|
|
- Switch to a branch and update all submodules to match:
|
2019-08-19 13:44:48 +01:00
|
|
|
|
|
|
|
`git switch --recurse-submodules {{branch_name}}`
|
|
|
|
|
2019-08-21 12:44:22 +01:00
|
|
|
- Switch to a branch and automatically merge the current branch and any uncommitted changes into it:
|
2019-08-19 13:44:48 +01:00
|
|
|
|
|
|
|
`git switch --merge {{branch_name}}`
|