# Git --- # REVIEW ---- ## TRY 1. Create a directory 2. Initialize Git 3. Create a file JASON wih "smell good" inside 4. commit it ---- ## RESULT ```bash git log && cat JASON ``` ```shell commit 81433feca060662a03b76a6e8d115e29f629c66b Author: N0Ball <n0ball@gmail.com> Date: Fri Jun 10 16:04:51 2022 +0800 ADD: file smell good ``` --- ## OOPS ---- ## I don't like this ---- ## Quick Reviews `STAGES` of git ---- ## Quick Review - Working Directory - Staging Area - Repo ---- ## How to get to the wanted version? ---- ## I don't like Working Directory :::success OFTEN USED COMMAND ::: ```bash git checkout . ``` - same as `add`, `.` for everything or you can type the filename you want to restore ---- ## QUICK TEST ```bash echo "OUO" > JASON ``` ```bash cat JASON ``` ```bash git checkout JASON ``` ```bash cat JASON ``` ---- ## I don't like Staging Area ```bash git restore --staged . ``` - same as `add`, `.` for everything or you can type the filename you want to restore ---- ## QUICK TEST ```bash echo "OUO" > JASON git add . ``` ```bash git status ``` ```bash git restore --staged JASON ``` ```bash git status ``` ---- ## I don't like REPO ```bash git reset ``` #### OPTIONS 1. `--soft` -> only changing status 2. `--hard` -> changes everything back to the commit status - Just like `git reset --soft` + `git checkout .` ---- ## QUICK TEST SOFT ```bash echo "OUO" > JASON git add . git commit -m "OOPS: wrong commit" ``` ```bash git log && cat JASON ``` ```bash echo "smell bad" > JASON git reset --soft xxxxx ``` - xxxxx is the commit id ```bash git log && cat JASON git status ``` ---- ## QUICK TEST HARD ```bash echo "smell bad" > JASON git add . git commit -m "OOPS: wrong commit" ``` ```bash git log && cat JASON ``` ```bash git reset --hard xxxxx ``` - xxxxx is the commit id ```bash git log && cat JASON git status ``` ---- ## I don't like COMMIT ```bash git commit --amend ``` ---- ## QUICK TEST ```bash echo "smell gooooooood" > JASON git add . git commit -m "ADD: discription of JES0N" ``` ```bash git log ``` ```bash git commit --amend -m "ADD: description for JASON" ``` ```bash git log ``` --- # REMOTE ---- ## LET'S REMOTE ---- ## REGISTRATION [register a gitlab account!](https://gitlab.dos.phy.ncu.edu.tw/users/sign_up) ---- ## GET REMOTE REPO :::success OFTEN USED COMMAND ::: `git clone <repo url>` ---- ## PreRequests ---- ## ADD ssh keys ![](https://i.imgur.com/OHATQRG.png) 1. Edit Profile (Top right corner) 2. SSH keys #### WHERE IS SSH KEYS ```bash ssh-keygen cat ~/.ssh/id_rsa.pub ``` ---- ## RESULT ![](https://i.imgur.com/tpqeBtK.png) ---- ## CONFIG in ~/.ssh/config ```shell Host gitlab.dos.phy.ncu.edu.tw PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa Port 1022 ``` #### TEST ```bash ssh -T git@gitlab.dos.phy.ncu.edu.tw ``` #### RESULT ```bash Welcome to GitLab, @<your user name>! ``` ---- ## Lets get a repository 1. GitLab (Top left corner) 2. Explore projects (Third tab) 3. All 4. Box 5. Clone 6. Clone with SSH ---- ```bash git clone git@gitlab.dos.phy.ncu.edu.tw:n0ball/box.git ``` ---- ## UPDATES :::success OFTEN USED COMMAND ::: `git pull`
{"metaMigratedAt":"2023-06-17T02:37:02.890Z","metaMigratedFrom":"YAML","title":"More Git","breaks":true,"GA":"UA-208228992-1","slideOptions":"{\"theme\":\"solarized\",\"transition\":\"fade\"}","contributors":"[{\"id\":\"bdcee32f-5dc2-4add-94fa-e418d7247ad0\",\"add\":3547,\"del\":129}]"}
    419 views