Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
strauss_d_getting_started_with_visual_studio_2022_learning_a.pdf
Скачиваний:
123
Добавлен:
26.06.2023
Размер:
17.04 Mб
Скачать

Chapter 5 Source Control

The status bar of Visual Studio will now show that you are currently pointed to a specific commit instead of to a branch (Figure 5-70).

Figure 5-70.  The Visual Studio status bar

You can now run your tests and modify code as required. You can even commit your code if required. To get back to your branch, simply select it from the branch selector in the Visual Studio status bar.

Line Staging

Also known as interactive staging, line-staging support is helpful when splitting changes across different commits. To enable this Preview Feature, ensure that the Enable linestaging option is enabled from the Preview Features section in the Options window as seen in Figure 5-71.

Figure 5-71.  Enable line-staging support

303

Chapter 5 Source Control

To see line staging in action, make some changes to one of your files, and then view the file in the Git Changes window as seen in Figure 5-72.

Figure 5-72.  Git Changes showing changed files

Next, double-click the file that you want to apply line staging to. Visual Studio will display a diff view of the selected file, allowing you to hover over the lines that you want to stage, and stage them individually as seen in Figure 5-73.

304

Chapter 5 Source Control

Figure 5-73.  Staging a specific line of code

Line staging also supports side-by-side and inline diff modes. Being able to stage specific lines of code is a nice feature and allows developers to be quite flexible when committing code.

Summary

Microsoft has added a lot of new features and enhancements to Visual Studio 2022. We had a look at cloning repositories, creating branches, and handling pull requests. Multirepo support is a fantastic new feature, and being able to compare commits, check out specific commits, and stage specific lines of code without leaving Visual Studio makes for a welcome productivity enhancement. I hope that you will continue exploring Visual Studio and embracing the rich set of features it provides.

305