Home > front end >  Which option to select to temporarily hold branch changes
Which option to select to temporarily hold branch changes

Time:10-07

  • I checked out the Main branch.
  • Created a new branch based on the main branch call One.
  • Completed the task and checked it back in.
  • Did the exact same steps but this time a new branch called Two.

Midway through the second task, i realise there is a bug in branch One. In Visual Studio 2022 i try and switch to branch One but prompted with 3 options

  1. Bring the changes to branch One.
  2. Stash the changes.
  3. Discard Changes.

I want to temporarily hold branch Two changes, resolve the bug in branch One check it in and then re-open branch Two from where i left off (So no changes are lost).

I'm pretty sure i need to select the second option but ive been bitten with GitHub before where i get myself into a bizarre situation and then i saw another couple of options within the Commit All button dropdown which has me confused Stash All (--include-untracked) and Stash All and keep staged (--keep-index)

Which option should i select so i can temporarily hold my changes until im ready to start the task under branch Two?

CodePudding user response:

--include-untracked

When used with the push and save commands, all untracked files are also stashed and then cleaned up with git clean.

--keep-index

All changes already added to the index are left intact.

  • Whichever option you choose, all changes in branch Two will be save in the stash, you can pop them later.

  • If changed files have been added into the change index, Choosing --keep-index will leave them intact in the working directory, unindexed changed files are always reverted.

  • Related