My Git cheat sheet

Create branch with current staged files

git switch -c new_branch -m
  • git switch: This command is used to switch to a different branch or create a new one.
  • -c new_branch: This option creates a new branch called new_branch. If the branch already exists, Git will throw an error.
  • -m: This option tells Git to move any changes from the current branch to the new branch.

Stash including untracked files

git stash --include-untracked

Allows you to temporarily save your changes in a “stash”.

The --include-untracked option tells Git to also include any untracked files in the stash, in addition to the tracked files that are already being modified.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *