1.3 KiB
1.3 KiB
Linux+ 4.4.1: Git basics
Configuring Git, a first repository and commit, ignoring files, staging and diffs, and a branch.
Before you start
Work as root, so ~ is /root. The lab only checks that ~/repo doesn't
exist yet, and notes whether you already have a ~/.gitconfig (reset
removes one the lab didn't find).
Tasks
- Install Git, set your name and email globally and make
mainthe default branch name. Create the repository~/repo, and commit an executable scripthello.shthat printshellowith the messageAdd hello script. - Make Git ignore
*.logfiles (createrun.logto see it), change the greeting inhello.shtohello, world, look at the unstaged and staged diffs, and commit everything with the messageGreet the world, ignore logs. - Create a branch
feature, append adateline tohello.shthere and commit it asPrint the date. Back onmain,hello.shhas no date line; compare the branches.
Hints
git config --global user.name,user.email,init.defaultBranch;git init,git status,git add,git commit -m..gitignore,git status --short,git diff,git add -A,git diff --staged,git log --oneline.git checkout -b feature(orgit switch -c),git commit -am,git log --oneline --graph --all,git diff main..feature.