Version Control Intro to Git(hub) 101 David O’Brien www.david-obrien.net, me@david-obrien.net, Senior DevOps Engineer Versent Fred Bainbridge www.fredbainbridge.com @FredBainbridge Now Micro
David O’Brien Fred Bainbridge @david_obrien @FredBainbridge MVP for Cloud and Datacentre Management MCSA Server 2012 @davidobrien1985 (github) www.david-obrien.net Infrastructure Automation, etc Aviation, automation, travel Beer and Baseball
Agenda Intro to Version Control What is a code repository? Let’s make a (git) baby Interactive demo
What is Version Control? Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.
GitHUB is NOT git. It’s a hosted service running on top of git, providing a few extra capabilities.
What is a Distributed Version Control system? no SPOF Git works with snapshots at the lowest level Every git commit is stored with a SHA-1 checksum 40c00c445112b9541bb6343e4af953431662b7c3 Almost impossible to lose data (in transit or at rest)
Git init
Git config git config user.email 'me@david-obrien.net' git config user.name "David O'Brien" git config --global user.email 'me@david-obrien.net' git config --global user.name "David O'Brien"
Git add / git commit
A commit’s insides Readme.md install.ps1 Install-Module IseSteroids # New project Info info yada yada Install-Module IseSteroids Install-Module -Name IseSteroids Commit A Commit B 5fd3 Readme.md 3cb1 install.ps1 5fd3 Readme.md 4a1e install.ps1 5fd3 3cb1 4a1e http://onlywei.github.io/explain-git-with-d3/ # New project Info info yada yada Install-Module IseSteroids Install-Module –Name IseSteroids
Recap https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
Git workflow A Dev’s step by step
Git clone git clone https://github.com/davidobrien1985/confdemos.git Cloning into 'confdemos'... remote: Counting objects: 348, done. remote: Total 348 (delta 0), reused 0 (delta 0), pack-reused 348 Receiving objects: 100% (348/348), 1.11 MiB | 391.00 KiB/s, done. Resolving deltas: 100% (112/112), done. Checking connectivity... done.
Let’s make a (git) baby Create a repo(sitory) or fork one We’ll use Github. However, Gitlab for example would work just as well. Clone it locally and start working
How and Why Resources Learn Git in a Month of Lunches Posh-Git Azure integration http://pcottle.github.io/learnGitBranching/ Why? This is really important. Want to learn more? Learn Git in a month of lunches is a good resource. There are a lot more out there and plenty of free resources available. The built in help menus are great too. Practice practice practice… For the system administrator git (source control) is a natural progression. Learn how to script and think you solved the riddles of the universe and then eventually determine you know very little. Develop strict naming and code formatting principals Create process and procedures for scripts in the enterprise Start using source control and wish you had used it the entire time. You want to take your scripting seriously. Always use source control. Always. No exceptions. Git is FREE and crazy powerful. It doesn’t require any server infrastructure or cost. Why wouldn’t you use it?
Visual Studio Team Services Project Management Agile\Scrum Workflow Custom Build stuff (DevOps) Azure Automation Source Control Git or VSTS Formerly Visual Studio Online. VSTS is another good option for source control. It has an opposite approach that github, all your repositories are private and you have to pay for publish repositories. GitHUB is the opposite, you have to pay for a private repository. VSTS also natively integrates with Visual Studio. So does GIT but it takes an extension.
What’s next? Sign up to Github or Gitlab Find a repo and fork it Put your own code into a repository (git init) Publish your code to Github or Gitlab
And Then …
Section Header This is the next section