File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed
src/content/docs-md/random Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -407,12 +407,38 @@ So this may look like so:
407407git diff feature/stuff -- src/stuff/my-stuff.html
408408```
409409
410- # Checkout Previous Branch
410+ # Checkout/Switch Branches
411+
412+ > Checking out/switching are similar taks with ` switch ` being the "newer" way to do things
413+
414+ There are some alternative methods for checking out branches depending on what you want to do:
415+
416+ ## Checkout/Switch from Current Branch
417+
418+ You can branch from your current branch with:
419+
420+ ``` sh
421+ git checkout -b feature/my-new-branch
422+ ```
423+
424+ ## Checkout/Switch from a Different Branch
425+
426+ Or you can checkout from another branch (e.g. ` main ` ) without switching to it first, this can be done with:
427+
428+ ``` sh
429+ # you may want to update your local copy of `main` first
430+ git fetch origin main:main
431+
432+ # and then switch to it
433+ git switch -c feature/my-new-branch main
434+ ```
435+
436+ # Checkout/Switch to Previous Branch
411437
412438When switching branches, we can easily go to the last branch we were on using:
413439
414440``` sh
415- git checkout -
441+ git switch -
416442```
417443
418444# Get Commit Changes from another Branch (Cherry Picking)
You can’t perform that action at this time.
0 commit comments