Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-switch: add page #3246

Merged
merged 4 commits into from
Aug 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions pages/common/git-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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}}`

- Create a new branch based on an existing commit:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"...and switch to it". Otherwise this is the same as git branch {{branch_name}} {{commit}}.


`git switch --create {{branch_name}} {{commit}}`

- Update all submodules to match the target branch:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Switch to a branch and update..."


`git switch --recurse-submodules {{branch_name}}`

- Automatically merge the current branch and any uncommitted changes into the new branch:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch is "new" only in the sense that we're switching into it, but that conflicts with the other use of "new" in this page. How about this:

Switch to a branch and automatically merge the current branch and any uncommitted changes into it:

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!


`git switch --merge {{branch_name}}`