19 An introduction to source control with Git

 

One sign of a professional toolmaker is their use of source control. How many of you have a folder on your C: drive in which you keep all of your scripts? Or maybe you have a network drive at your work with all the IT scripts? Because we’re in automation and DevOps, properly maintaining our PowerShell projects is critical. For many organizations today, this task falls to Git, a source control system first made famous on Linux (it was invented by Linux’s inventor, Linus Torvalds). We thought it would be helpful to provide a crash course on Git fundamentals so that you can begin incorporating it into your work. As you might expect, this is a significant topic; you’ll need to devote time to learning more than the basics. You may want to look at Learn Git in a Month of Lunches by Rick Umali (Manning, 2015, http://mng.bz/mj7P).

19.1 Why source control?

Source control is a means of keeping track of what changes have been made to a file, often including a change log or documentation that indicates who made a change and why. Source control also makes knowing the latest or more authoritative version easier. Some systems require you to check out a file to work on it. When you’re finished, you can check it in, often with a comment about what you modified and why. While the file is checked out, only you can work with it, which may be fine for smaller teams.

19.2 What is Git?

19.2.1 Installing Git

19.2.2 Git basics

19.3 Repository basics

19.3.1 Creating a repository

19.3.2 Staging a change

19.3.3 Committing a change

19.3.4 Rolling back a change

19.3.5 Branching and merging

19.4 Using Git with VS Code

19.5 Integrating with GitHub

Summary