2.0 KiB
2.0 KiB
Linux+ 4.4.2: Working with remotes and history
A bare "server" repository, pushing, cloning, fetching and pulling, a squash merge, an annotated tag, the stash, and undoing commits.
Before you start
Work as root, so ~ is /root. The lab installs Git and creates ~/repo
as chapter 4.4.1 leaves it: main with the commits Add hello script
and Greet the world, ignore logs, and a branch feature with the
commit Print the date. If you have no Git identity or default branch
name yet, it sets them in ~/.gitconfig as chapter 4.4.1 does (reset
removes the file again). It checks that ~/remote.git and
~/repo2 don't exist yet. Don't run the chapter's clean-up step:
le-lab reset does it.
Tasks
- Create the bare repository
~/remote.git, add it to~/repoasorigin, pushmainandfeatureto it (setting the upstream), and clone it to~/repo2. - In
~/repo2, add a fileREADMEcontainingLab scripts, commit it asAdd a READMEand push it. In~/repo, fetch, see the new commit withgit log main..origin/main, and pull it. - In
~/repoonmain, squash-mergefeatureand commit it asPrint the date (squashed). Tag that commit asv1.0with the messageFirst release. Then appendwiptohello.sh, stash the change, look at the status, and pop the stash again. - Commit everything as
Oops, then undo that commit with a soft reset (keeping the change staged), unstage it and throw it away. Finally undo the squashed commit without rewriting history, withgit revert.
Hints
git init --bare,git remote add origin,git push -u origin main feature,git clone.git push,git fetch,git log --oneline main..origin/main,git pull.git merge --squash feature,git commit -m,git tag -a v1.0 -m,git log --oneline --decorate,git stash,git stash pop.git commit -am,git reset --soft HEAD~1,git restore --staged,git restore,git revert --no-edit HEAD.