Welcome to Part 2 of this review of the Pluralsight course Using Git with a GUI by Xavier Morera.
Xavier is an entrepreneur, project manager, technical author, trainer, Certified Scrum Professional & Scrum Master and Certified Microsoft Professional and Microsoft MVP.
He has spent a great deal of his career working on cutting-edge projects with a primary focus on .NET, Solr and occasionally iOS. He’s also a fellow Simple Programmer blogger.
What You Need to Know About Git
Xavier begins with a short history of Git, and then explains what Git is and the features that it offers.
Git Branches Are Different
Most source control systems have branches but they:
– Are expensive
– Are used to mark milestones
– Merging can make you cry
Branches in Git are:
– Part of Daily workflow
– We branch and merge all the time
– Easily enables parallel development
– Takes daily development to new levels of productivity
Xavier also describes branching for testing scenarios
Working with Git
We see a typical Git workflow:
– Origin Repository where we fork from
– Clone to local repository
– Branch to work on feature
– Merge feature to local repository
– Push changes into the origin repository
Later we will also learn about the pull request
In this lesson we learn about the Git Object Model.
– We have multiple different types of objects which are referenced by a SHA1 hash.
– The hash is used both as an identifier and for data integrity.
– Each object consists of a type, size and content
– Types of object are Blob, Tree, Commit and Tag
Finally Xavier explains how Git stores our data, but warns never to mess with the .git directory
We can get more information about the different Git object by using the git show command.
For advanced Git concepts see Enrico Campidoglio’s Advanced Git Tips and Tricks course
Starting with Our Repositories
Xavier also recommends Atlassian Bitbucket.
Alternatives are GitHub, bare Repositories, Stash (Bitbucket Server), Bonobo and others.
BitBucket
We see how too signup to Bitbucket.org and a little about how to get started there.
This lesson also covers Naming Recommendations for your projects
– Descriptive
– Readable
– Consistent
– Contextual
– Future-friendly
We hear a couple of examples of great project names that meet all of these criteria
Demo: BitBucket
We see how to clone our repository from BitBucket.
The difference between BitBucket and SourceTree is BitBucket is a repository in the cloud,
and SourceTree is the client we use to access Git repositories.
GitHub
We see how to signup with Github.com, how to download GitHub Desktop, and what is Git Shell?
Demo: GitHub
We find Nicolas Carlo’s gitgraph.js project on GitHub, copy the link to it, paste it into SourceTree’s clone repository window, and clone it locally.
Bare Repositories
In the command line:
git init –bare
He warns that no one should ever make direct edits to the files.
Xavier explains and shows some of the differences between this and cloud based repositories (working repositories).
Demo: Bare Repository
We start by creating a new repository locally.
The .git folder tells us that we are working with a working directory (not a bare repository).
Using the terminal we can create a bare repository using Git:
$ git init –bare ~/Documents/using-git-bare.git
We see side by side the difference between a working repository and a bare repository.
The bare repository has the following directories:
– branches
– hooks
– info
– objects
– ref
It also has config, description and HEAD files.
Xavier goes to the “Add Working Copy” tab of the Clone / Add / Create New Repository
In the Working Copy Path, Xavier pastes in the file path of the BARE repository.
SourceTree detects that this is incorrect and displays “Repository Type: This is not a valid working copy path.”
Next he goes to the Clone Repository tab and pastes it into “Source Path / URL”.
This time it displays: “Repository Type: This is a Git repository”
We see how to connect to a bare repository that’s stored locally.
Git: Enterprise or Open Source?
Xavier begins by talking about Git in Open Source. GitHub has been a sort of social network for coding.
Git is also perfect for Enterprise, and works for small, medium and large companies.
Security with SSH
SSH stands for Secure Shell and is an cryptographic alternative to using Username and password.
It identifies trusted computers without involving passwords.
Xavier says SSH is more secure than using usernames and passwords, but also a bit more complex.
He also talks about using a Proxy to connect with the outside world.
Demo: SSH
We see how to generate a key with the PuTTY Key Generator, which is found in the Tools menu.
Once generated, we copy it and go to BitBucket’s SSH keys menu. Here we give it a Label and add it.
Next, we create a PuTTY private key and save it.
We can import our private key that matches the public key that we’ve added to Bitbucket so that they can connect.
Using the file explorer we find our saved private key. Then in the Options window we click OK.
Xavier also shows how to test that this works.
The first thing that we expect to see in our repository is SSH instead of HTTPS showing to the left of our file path
If you copy this URL and clone it, we might see a message that the key hasn’t been cached.
We should agree to accept the server’s key and retry the operation.
We see that SourceTree detects that we have a valid Git repository, and we are allowed to clone it without any username or password.
Xavier also shows us the PuTTY authentication agent which shows us our Pageant key list.
Overview of Migrating to Git
Xavier says migrating to Git requires:
– Planning & preparation
– Tools and scripts
Once it is converted we pick a workflow.
Make sure you see the different branching strategies later on in this course.