mirror of
https://github.com/jbranchaud/til
synced 2026-01-04 23:58:01 +00:00
Add Create A New Branch With Git Switch as a git til
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
|
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
|
||||||
|
|
||||||
_1024 TILs and counting..._
|
_1025 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -226,6 +226,7 @@ _1024 TILs and counting..._
|
|||||||
- [Clone A Repo Locally From .git](git/clone-a-repo-locally-from-git.md)
|
- [Clone A Repo Locally From .git](git/clone-a-repo-locally-from-git.md)
|
||||||
- [Configure Global gitignore File](git/configure-global-gitignore-file.md)
|
- [Configure Global gitignore File](git/configure-global-gitignore-file.md)
|
||||||
- [Configuring The Pager](git/configuring-the-pager.md)
|
- [Configuring The Pager](git/configuring-the-pager.md)
|
||||||
|
- [Create A New Branch With Git Switch](git/create-a-new-branch-with-git-switch.md)
|
||||||
- [Delete All Untracked Files](git/delete-all-untracked-files.md)
|
- [Delete All Untracked Files](git/delete-all-untracked-files.md)
|
||||||
- [Determine The Hash Id For A Blob](git/determine-the-hash-id-for-a-blob.md)
|
- [Determine The Hash Id For A Blob](git/determine-the-hash-id-for-a-blob.md)
|
||||||
- [Diffing With Patience](git/diffing-with-patience.md)
|
- [Diffing With Patience](git/diffing-with-patience.md)
|
||||||
|
|||||||
27
git/create-a-new-branch-with-git-switch.md
Normal file
27
git/create-a-new-branch-with-git-switch.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Create A New Branch With Git Switch
|
||||||
|
|
||||||
|
As of [Git 2.23](https://www.infoq.com/news/2019/08/git-2-23-switch-restore/),
|
||||||
|
there is a new command in town for change and creating branches --
|
||||||
|
`git-switch`.
|
||||||
|
|
||||||
|
As a git user, you may be used to using `git checkout -b my_branch` to create
|
||||||
|
and switch to a new branch called `my_branch`. The `git-checkout` command can
|
||||||
|
do that and a lot more. In order to reduce some confusion and create a more
|
||||||
|
explicit command for this kind of action. That's what brought about
|
||||||
|
`git-switch`.
|
||||||
|
|
||||||
|
Create and change to a new branch with `git-switch` and the `-c` flag:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git switch -c my_new_branch
|
||||||
|
```
|
||||||
|
|
||||||
|
The `-c` flag is short for `--create` and the docs describe it as "a convenient
|
||||||
|
shortcut for:"
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git branch <new-branch>
|
||||||
|
$ git switch <new-branch>
|
||||||
|
```
|
||||||
|
|
||||||
|
See `man git-switch` for more details.
|
||||||
Reference in New Issue
Block a user