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

Moves all your changes to your newly created branch, after wrongfully making changes to master #2513

Open
khabubu opened this issue May 7, 2020 · 4 comments

Comments

@khabubu
Copy link

@khabubu khabubu commented May 7, 2020

Is your feature request related to a problem? Please describe.
I'm always frustrated when I make changes to master branch and what to switch those changes to a new branch or an existing branch.

Describe the solution you'd like
I would like to be able to switch to a new or existing branch and move those changes to that brunch
through a user interface where I can switch to branch with changes.

Describe alternatives you've considered
The current alternative is to open the command prompt and enter the following command

𝚐𝚒𝚝 𝚜𝚠𝚒𝚝𝚌𝚑 -𝚌 "𝚢𝚘𝚞𝚛_𝚗𝚎𝚠_𝚋𝚛𝚊𝚗𝚌𝚑"

Or if the branch already exists

𝚐𝚒𝚝 𝚜𝚠𝚒𝚝𝚌𝚑 "𝚢𝚘𝚞𝚛_existing_𝚋𝚛𝚊𝚗𝚌𝚑"
@jcansdale
Copy link
Collaborator

@jcansdale jcansdale commented Jul 6, 2020

@daschult,

I think this is more of a new Get Experience feature request. Do you know if there's an easy way to move your changes to a different branch using the new UI? This is certainly a frustration I've had when using Git in the past!

@daschult
Copy link
Collaborator

@daschult daschult commented Jul 7, 2020

Hi Khabubu,

I'm just trying to understand your scenario a little bit better. You situation looks like this, right?

  1. Accidentally make commits to master branch.
  2. You create a new branch off of master.
  3. You switch to new branch.

I think you can accomplish this pretty simply by just "git checkout -b " from master. If you want to reset master to before the accidental commit, then you can run "git reset --hard ". You can also do all of this using Team Explorer or the Git tool window in Visual Studio. Before I go into those instructions, though, do you feel like I'm understanding your scenario?

Thanks!

@khabubu
Copy link
Author

@khabubu khabubu commented Jul 8, 2020

Hi Dan

You have partially understood my scenario. In my scenarioI have not yet commited to master branch but I have changed a file while on the master branch and I don't want to lose the changes. Now your alternative is valid if I had commited to the master brunch hence the you have suggested to use "git checkout -b", however I want to use the new UI to switch between the local master branch to another local branch withou losing those changes.

Hence I provided the current alternative I use which is using the command line and execute the following command "git switch dev".

@jcansdale
Copy link
Collaborator

@jcansdale jcansdale commented Jul 9, 2020

@daschult,

The situation I would often get into was this:

  1. I'm reviewing someone's pull request on a branch
  2. I notice and fix an unrelated bug, forgetting to create a new branch
  3. I try to change to the default branch, but can't because the file I touched has changed
  4. At this point, I need to Stash, change to the default branch, pop my Stash (and pray there are no merge conflicts)

I wish there was a streamlined way to do 4 ☝️

Reading up on the git switch command that @khabubu mentioned (see here), I think this might be the command I'm looking for!

image

Maybe this is simply a case of the new Git experience using the new git switch command instead of the legacy git checkout command. I always found checkout's insistence on a clean working tree to be a burden (particularly when working with submodules).

In summary, I think it's a great idea to consider using git switch either as the default or at least an option!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.