This is a workshop for developers familiar with Git.
In this workshop, you'll practice version control techniques such as:
git pull --rebase
. Pull current branch, but move local commits on top of remote commits (instead of merging)git merge --squash <branch>
. Merge multiple commits from a branch into a single commitgit commit --amend
. Update last commit with different files or messagegit reset HEAD~1
. Undo last commit, but keep changes in filesgit cherry-pick <commit>
. Copy specific commit from another branchgit rebase <branch>
. Copy all commits from another branchgit add -p <file>
. Commit only part of your changesgit log --source --all -S <string>
. Find commit that added / removed a stringgit blame
. Show who made the last change to each line, and whengit log --graph --all --pretty=format:"%h%x09%d%x20%s (%cn %ad)" --date=relative
. Show all commits across branches in a graphgit config --global core.autocrlf false
. Disable automatic line endings conversion in Windows
This repository has 4 branches: master
, branch-1
, branch-2
, and branch-3
in this structure:
* ....... (master) latest commits
* c30606f Add README.md
| * a50a8d3 (branch-2) Add genre
| * e1c06b2 Add original title (same as title)
| * 5088aa1 Add language
|/
| * 7100614 (branch-3) Add Amazon link
| * 90ab24f Add Goodreads link
| * 45cc81b Add publisher
|/
| * 87dbea0 (branch-1) Add author as Harry Potter
| * 5dd0d28 Add published date
|/
* 3ac9850 Add minimal styling
* b405c09 Add list of fields
* f294165 Add book description
* 9618a3c Add book heading
* 118d128 Create base scaffolding for a Harry Potter book page
You need to:
- Fork this repo into your namespace and clone your fork
- Checkout
branch-1
and undo the last commit, which is incorrect ("Add author as Harry Potter") - In
branch-1
, add a new commit with the text<p>Author: JK Rowling</p>
(commit message: "Add author") - Merge-squash the
branch-1
branch on tomaster
(commit message: "Add published date and author") - Cherry-pick the 1st and 3rd commits in
branch-2
intomaster
- Rebase
branch-3
on top ofmaster
, fixing merge conflicts - Merge
branch-3
intomaster
and push themaster
branch into your repo - Find the commit ID that first added the word
FIELDS
- Find the commit ID to blame for the
<link>
tag in index.html - Create an issue titled
Exercise submission
with this description:- Link to repo: _______
- Commit ID adding FIELDS: _______
- Commit ID to blame for
<link>
: _______
You can test if your commits are correct by running pytest
locally.