Version control
Every change is kept, with who, when and why
Version control records each change, so you can see it, undo it and share it.
Start with the problem. Without version control, a project becomes a pile of copies. Final. Final version two. Nobody is sure which is current, or who changed what. With version control there is one project and a history. Each step in the history is a recorded change, with an author and a message. So for every change you know who made it, when, what it was and why. And you can always go back.
Version control · Going deeper
What version control gives you
History, undo, collaboration and branching. Git is distributed.
Git and GitHub
Git is the tool. GitHub is where you share it
Git records history on your machine. GitHub hosts it and adds collaboration.
The exam always asks this difference. Git is a tool that runs on your own machine. It makes commits, branches and merges, and it keeps the full history. It needs no network. GitHub is a service on the internet that hosts Git repositories. Around the code it adds pull requests, issues, automation and access control. The two are joined by push and pull. Push sends your commits up. Pull brings other people's down.
Git and GitHub · Going deeper
Git and GitHub side by side
Pull requests, issues, forks and stars are GitHub ideas, not Git.
Check yourself
With the connection down, which of these still works?
Repositories, commits, branches
A branch is a name that points at a commit
A repository holds commits. A branch is a movable label on one of them.
Three words to make exact. A repository is the project together with its whole history. The history is a chain of commits. A commit is a snapshot of every file at one moment. It has an I D, an author, a message, and a pointer to the commit before it. A branch is just a name that points at a commit. This one is main. Create a second branch and commit to it, and a new line of work grows. Main does not move.
Repositories, commits, branches · Going deeper
The Git words to know
HEAD, clone, remote, origin, tag and .gitignore.
The basic workflow
Add, commit, push: three moves to GitHub
git add stages, git commit records, git push shares. git pull brings changes back.
How does a change get from your editor to GitHub? You edit files in the working directory. Git add puts the changes you choose into the staging area. That is the list for your next commit. Git commit records them in the repository on your machine. Git push sends your commits to GitHub. Until you push, nobody else can see them. And git pull goes the other way, bringing down what others have pushed.
The basic workflow · Going deeper
The basic Git commands
Ten commands. git pull is fetch followed by merge.
Check yourself
How many commits does feature have that main does not?
Merging
A merge joins two lines of work into one
A merge brings a branch into main. A merge conflict needs a person to decide.
Branches are made to come back together. Before the merge there are two lines. Main stopped at C three. The feature branch has two more commits. Merging feature into main creates a merge commit. It has two parents, so main now holds the work of both lines. Most of the time Git does this by itself. When both sides changed the same lines, it stops and reports a merge conflict, and a person chooses.
Merging · Going deeper · 1 of 2
Merge methods and conflicts
Merge commit, squash or rebase: three buttons on a pull request.
Merging · Going deeper · 2 of 2
Clue words for Git and GitHub
Commit, branch, clone, push, pull and merge.
Check yourself
notes.md is where the drawing shows. Which command records it in the history?
Lesson complete
You finished “Version control, Git and GitHub”
Answer the questions along the way to see your score here.