do the assignment first. reading the answer is not the same as doing it, and u will feel like u learned it when u didn’t.
# 1
ssh-keygen -t ed25519 -C "ur_email@example.com"
cat ~/.ssh/id_ed25519.pub # paste this on github, Settings > SSH keys
ssh -T git@github.com
# 2
# make the repo on github first (empty, no README), then:
cd practice-git
git remote add origin git@github.com:username/practice-git.git
# 3
git remote -v
# 4
git push -u origin main
# 5
git remote set-url origin git@github.com:username/wrong-name.git
git remote -v
git remote set-url origin git@github.com:username/practice-git.git
# 6
cd ..
git clone git@github.com:username/practice-git.git practice-clone
# 7
cd practice-clone
echo "from the clone" >> notes.md
git commit -am "a change from the clone"
git push
cd ../practice-git
git fetch
git status
# 8
git pull
# 9
echo "DB_PASSWORD=hunter2" > .env
mkdir node_modules && echo "junk" > node_modules/a.js
printf 'node_modules/\n.env\n' > .gitignore
git status -s
# 10
git check-ignore -v .env node_modules/a.js
# 11
git add -f .env
git commit -m "oops, committed the env file"
git rm --cached .env
git commit -m "stop tracking .env"
git status -s
# 12
echo "my-scratch.md" >> .git/info/exclude
echo "personal notes" > my-scratch.md
git status -soutput of 1:
Hi Mohamedattiadev! You've successfully authenticated, but GitHub does not provide shell access.
output of 7, the git status part:
On branch main
Your branch is behind 'origin/main' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working tree clean
output of 10:
.gitignore:2:.env .env
.gitignore:1:node_modules/ node_modules/a.js
output of 11, after git rm --cached .env and before the commit:
D .env
output of 11, after the commit:
(nothing at all, and `.env` is still there in `ls -a`)
- in step 7, notice
fetchchanged nothing in ur files. it only told u the remote moved.pullin step 8 is what actually brought the commit into ur branch. - in step 11, the
Dis a staged deletion, not a lost file: u are removing it from git, and that removal has to be committed like anything else. once it is committed the file is untracked,.gitignorefinally hides it, andgit statusgoes quiet.ls -aproves the file is still on ur disk. and remember: the commit u already made still has the password in it. in real life u change the password, u do not just untrack the file. - in step 12, nothing appears in
git statusand nothing appears in.gitignoreeither. that rule lives in.git/info/exclude, and.gitis never pushed.