4

VS2019 Git 功能改版

 3 years ago
source link: https://blog.darkthread.net/blog/vs2019-new-git-experience/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

VS2019 Git 功能改版

2020-12-10 09:00 PM 0 1,445

為了升級 ASP.NET Core 5.0,我把 Visual Studio 2019 升到 16.8,發現 Git 介面做了大幅革新,新介面更好用,但要花點時間熟悉。

完整介紹可以看 Visual Studio PM Patrik 的部落格文章 - Announcing the Release of the Git Experience in Visual Studio,這篇是我自己的整理。

原本 Git 相關操作都集中在 Team Explorer,新版獨立出一個 Git Changes 頁籤以及一個全視窗的 Git Repository 檢視器,一些功能則分散整合進 Visual Studio 介面的不同地方。

如果你跑去 Team Explorer 想用 Git 功能,會看到一則搬家啟事:

Fig1_637432022514714951.png

註:若真心無法習慣新介面,可以選擇切回舊版介面:(不過,Partik 在部落格文章誠心想知道選擇關閉的朋友哪裡用得不開心呢?希望大家透過問題回報表達心聲,而我認為將 Git 操作提升成 Visual Studio 標準功能是既定政策,遲早要適應這些改變)

Fig2_637432022515497067.png

接下來,來盤點原本放在 Team Explorer 的 Git 功能到哪裡去了。

首先,Git 在頂部選單有了自己的專區,可用來 Clone 或開啟 Git Repository,還有 Commit / Stash、Fetch、Pull、Push、開 Branch、看歷程... 等基本操作。

Fig4_637432022515949495.png

檔案選單也有 Clone 或開啟 Git Repository 選項:

Fig5_637432022516834723.png

Git Global Settings 跟 Git Repository Settings 移到 Tools/Options/Source Control 去了,要開啟沒以前方便:

Fig3_637432022517360039.png

修改程式後要提交內容,Git Changes 即為以前 Team Explorer 中的 Changes,會自動偵測檔案修改增刪,可選取提交哪些檔案、輸入訊息後提交 Commit,而上方多了 Branch 切換、Fetch、Pull、Push 等按鈕可直接點選,比之前要切到 Sync 才能操作方便不少。

Fig6_637432022517850515.png

新增的 Git Repository 檢視視窗是本次改版的最大亮點:

Fig7_637432022518421706.png

終於能在單一個介面看到所有分支狀態,對我來說這功能很重要。先前用 View Hisotry 只能看單一 Branch,逼得我另開 VSCode + Git Graph 了解全貌。左側的 Branch 清單可以使用原本 Team Explorer/Branch 的分支管理功能:

Fig8_637432022518821935.png

對照之前 View History 只能檢視單一 Branch 歷程:

Fig3_637422089210498851.png

新版可以看到其他 Branch 的相對位置(下圖紅標籤),資訊更完整:

Fig9_637432022519234167.png

依我的觀點,這次調整背後有個重大意義 - Git 不再只是版控選項之一,已被視為開發活動的必要程序。Git 的各種操作功能原本集中在小小的 Team Explorer 視窗,改成穿插融入到 Visual Studio UI 各角落,成為 Visual Studio 的標準支援項目。而由此也不難看出,Git 已漸成為開發者必備的技能(例如:如果你想應徵台積電軟體工程師 - Familiar with source code version control tools : Git),建議還沒上手的朋友加快腳步。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK