I’m trying to take the next step in my PowerShell journey by using Git and GitHub repos for source control. I understand the general concepts of Git (diffs, branches, commits, etc), and I have Git installed and working with VS Code, but I’m struggling with the finer details of setting up my work environment and actually using Git. My background is help desk and sysadmin, so I have no formal training or experience with software development. I would like to establish good Git habits now that will apply to both personal and team scenarios in case I ever work on a team that uses Git in the future. Here are the questions I have that I’m struggling with. I greatly appreciate any advice and tips in advance.
- Should I use a VS Code workspace for PowerShell coding (File > Save Workspace As)? If so, would each project or repo have its own workspace, or would I have just one workspace for PowerShell coding? What are the benefits, specifically related to PowerShell coding, of using a workspace?
- What is the typical practice when it comes to working with folders in VS Code? For example, at work I store all my PowerShell files in my home folder on the network (H:\PowerShell) and have subfolders for Azure, Active Directory, Exchange, etc. Currently, I have H:\PowerShell added as a folder in my workspace so I can quickly browse to any of the subfolders. I was also thinking it would be convenient to add the local default PowerShell module folders to the workspace for managing modules. Is this normal, or is it better to open and close individual folders as you work on files within them in VS Code?
- Where should I save local Git repos I plan on syncing with GitHub, and how should I work with them in VS Code? Should I create a single top-level folder in my OneDrive (C:\Users\<username>\OneDrive\GitHub) and subfolders for each local repo? When I work with the repos in VS Code, should I add the entire GitHub top-level folder to the workspace, or should I only add the repos I’m working on?
- What is the order of operations when working with Git in VS Code? When do you test your code? Is it before or after your stage your changes, or is it before or after you commit your changes to the local repo? When do you sync the local repo to the GitHub repo?