0

When I switch to some specific commit of a branch of a solution in one instance of MS VS, it also makes the same switch automatically in the other instance... . Is there a setting I should change to avoid this?

So I have basically, what I think is, one solution, with multiple branches in github. Each of these branches has many different commits.

So let's say I want to copy quite some code from branch 6, commit x-10, to branch 1, the latest commit there. How can I have both branches open in different instances of Microsoft Visual Studio 2022 ? For now they are, I think, all linked to the same repository. Maybe that is the problem.

Now, VS changes all the files in its solution directory when I switch solution. I guess that's why I can't open different branches/commits in different instances of MS VS.

How can I avoid that? MS VS 2022. I'm using C++ projects.

7
  • 3
    The HEAD state (the current commit) is a property of the worktree. If you want different HEAD states, you need separate worktrees. Commented Jun 21 at 13:30
  • 1
    visual studio listens to what the repo is doing Commented Jun 21 at 13:33
  • 1
    As @RaymondChen mentioned, you can use multiple worktrees, or if your repo isn't too large, you could even have multiple clones of the repo locally. But you may not need either of those, depending on what "copy quite some code" means. You can view versions of specific files at any commit in many UI tools (or from the command line), and copy the desired portions of those files without changing your working HEAD state. Or, even easier, you can copy files entirely from another commit and place them in your current working tree. (Which do you prefer- copying portions or the entire files?)
    – TTT
    Commented Jun 21 at 15:00
  • @RaymondChen: Thx. Will look into this. I have already different branches, but might need to specify a new work directory somehow. A worktree in the context of Git and GitHub refers to an additional working directory for a single repository.
    – babipsylon
    Commented Jun 22 at 11:52
  • @DanielA.White: Ok. Meaning what exactly in this context?
    – babipsylon
    Commented Jun 22 at 11:53

0

Browse other questions tagged or ask your own question.