LFCA 5.2: Git concepts
A first repository, a merge conflict, a bare repository as a remote, and
undoing a commit with git revert.
Before you start
Work as root (sudo -i), so ~ is /root. The lab only checks that
~/project, ~/app.git and ~/app-copy don't exist yet, and notes
whether you already have a ~/.gitconfig and Git (reset removes the ones
the lab didn't find).
Tasks
- Install Git, set your name and email (and
init.defaultBranch main, as the chapter shows), create the repository~/project, make three commits onmain, and read the log withgit log --oneline. - Make a branch, change the same line on it and on
main, merge the branch intomain, and resolve the conflict. - Create a bare repository with
git init --bare -b main ~/app.gitto act as a remote, and push~/project'smainto it. Clone it into~/app-copy, commit a change there and push it, thenpullthe change back into~/project. - In
~/project, commit a bad change, then undo it withgit revert, and read the log.
Hints
git config --global user.name,user.email,init.defaultBranch;git init ~/project,git add,git commit -m.git switch -c NAME,git switch main,git merge NAME; edit the file to remove the<<<<<<<,=======and>>>>>>>lines, thengit addandgit commit.-b mainnames the bare repository's default branch. Without it orinit.defaultBranch, it'smaster, and the clone warns "remote HEAD refers to nonexistent ref" and comes out empty.git remote add origin ~/app.git,git push -u origin main,git clone ~/app.git ~/app-copy,git push,git pull.git revert HEAD,git log --oneline.