From bd16245b95efe6df27e3995e0d135dba3b0926b3 Mon Sep 17 00:00:00 2001 From: Sarah M Brown Date: Wed, 21 Sep 2022 21:53:41 -0400 Subject: [PATCH 1/3] iniitla dump --- _toc.yml | 1 + notes/2022-09-21.md | 429 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 430 insertions(+) create mode 100644 notes/2022-09-21.md diff --git a/_toc.yml b/_toc.yml index be16c85..5af08ac 100644 --- a/_toc.yml +++ b/_toc.yml @@ -20,6 +20,7 @@ parts: - file: notes/2022-09-12 - file: notes/2022-09-14 - file: notes/2022-09-19 + - file: notes/2022-09-21 - caption: Activities chapters: - file: activities/kwl diff --git a/notes/2022-09-21.md b/notes/2022-09-21.md new file mode 100644 index 0000000..83e102d --- /dev/null +++ b/notes/2022-09-21.md @@ -0,0 +1,429 @@ +# How should I use git in this class + + +```{warning} +this is currenlty only the raw output from the shell session. Annotation will be added tomorrow +``` + +```bash +git status +On branch main +Your branch is up to date with 'origin/main'. + +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git restore ..." to discard changes in working directory) + modified: README.md + modified: about.md + +Untracked files: + (use "git add ..." to include in what will be committed) + CONTRIBUTING.md + LICENSE.md + docs/ + mymodule/ + overview.md + setup.py + tests/ + typescript + +no changes added to commit (use "git add" and/or "git commit -a") +``` + +```bash +git checkout -b organtzation +Switched to a new branch 'organtzation' + +``` + +```bash +git status +On branch organtzation +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git restore ..." to discard changes in working directory) + modified: README.md + modified: about.md + +Untracked files: + (use "git add ..." to include in what will be committed) + CONTRIBUTING.md + LICENSE.md + docs/ + mymodule/ + overview.md + setup.py + tests/ + typescript + +no changes added to commit (use "git add" and/or "git commit -a") + +``` + +```bash +git add . + +``` + +```bash +git commit -m 'from inclass org acitivyt' +[organtzation 8b62af8] from inclass org acitivyt + 23 files changed, 69 insertions(+) + create mode 100644 CONTRIBUTING.md + create mode 100644 LICENSE.md + create mode 100644 docs/API.md + create mode 100644 docs/_config.yml + create mode 100644 docs/_toc.yml + create mode 100644 docs/about.md + create mode 100644 docs/example.md + create mode 100644 docs/overview.md + create mode 100644 docs/philosophy.md + create mode 100644 mymodule/__init__.py + create mode 100644 mymodule/abstract_base_class.py + create mode 100644 mymodule/alternative_classes.py + create mode 100644 mymodule/helper_functions.py + create mode 100644 mymodule/important_classes.py + create mode 100644 overview.md + create mode 100644 setup.py + create mode 100644 tests/test_alt.py + create mode 100644 tests/test_help.py + create mode 100644 tests/test_imp.py + create mode 100644 tests/tests_abc.py + create mode 100644 typescript + +``` + +```bash +git push +fatal: The current branch organtzation has no upstream branch. +To push the current branch and set the remote as upstream, use + + git push --set-upstream origin organtzation + + +``` + +```bash +git remote +origin + +``` + +```bash +git push --set-upstream origin organtzation +Enumerating objects: 11, done. +Counting objects: 100% (11/11), done. +Delta compression using up to 8 threads +Compressing objects: 100% (7/7), done. +Writing objects: 100% (8/8), 1.68 KiB | 1.68 MiB/s, done. +Total 8 (delta 0), reused 0 (delta 0), pack-reused 0 +remote: +remote: Create a pull request for 'organtzation' on GitHub by visiting: +remote: https://github.com/introcompsys/github-inclass-brownsarahm/pull/new/organtzation +remote: +To https://github.com/introcompsys/github-inclass-brownsarahm.git + * [new branch] organtzation -> organtzation +branch 'organtzation' set up to track 'origin/organtzation'. + +``` + +```bash +git fetch +From https://github.com/introcompsys/github-inclass-brownsarahm + * [new branch] 2-create-an-about-file -> origin/2-create-an-about-file + +``` + +```bash +git status +On branch organtzation +Your branch is up to date with 'origin/organtzation'. + +nothing to commit, working tree clean + +``` + +```bash +git branch + main +* organtzation + +``` + +```bash +git checkout 2-create-an-about-file +branch '2-create-an-about-file' set up to track 'origin/2-create-an-about-file'. +Switched to a new branch '2-create-an-about-file' + +``` + +```bash +echo "test" >> about.md + +``` + +```bash +git status +On branch 2-create-an-about-file +Your branch is up to date with 'origin/2-create-an-about-file'. + +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git restore ..." to discard changes in working directory) + modified: about.md + +no changes added to commit (use "git add" and/or "git commit -a") + +``` + +```bash +cat about.md +test + +``` + +```bash +git add . + +``` + +```bash +git comit -m 'start about' +git: 'comit' is not a git command. See 'git --help'. + +The most similar command is + commit + +``` + +```bash +git commit -m 'start about' +[2-create-an-about-file 30c4748] start about + 1 file changed, 1 insertion(+) + +``` + +```bash +git push +To https://github.com/introcompsys/github-inclass-brownsarahm.git + ! [rejected] 2-create-an-about-file -> 2-create-an-about-file (fetch first) +error: failed to push some refs to 'https://github.com/introcompsys/github-inclass-brownsarahm.git' +hint: Updates were rejected because the remote contains work that you do +hint: not have locally. This is usually caused by another repository pushing +hint: to the same ref. You may want to first integrate the remote changes +hint: (e.g., 'git pull ...') before pushing again. +hint: See the 'Note about fast-forwards' in 'git push --help' for details. + +``` + +```bash +git fetch +remote: Enumerating objects: 5, done. +remote: Counting objects: 100% (5/5), done. +remote: Compressing objects: 100% (2/2), done. +remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 +Unpacking objects: 100% (3/3), 643 bytes | 214.00 KiB/s, done. +From https://github.com/introcompsys/github-inclass-brownsarahm + 3c9980a..8ce03aa 2-create-an-about-file -> origin/2-create-an-about-file + +``` + +```bash +cat about.md +test + +``` + +```bash +ls -a +. .git README.md +.. .github about.md + +``` + +```bash +ls .git +COMMIT_EDITMSG config index objects +FETCH_HEAD description info packed-refs +HEAD hooks logs refs + +``` + +```bash +git checkout 2-create-an-about-file +Already on '2-create-an-about-file' +Your branch and 'origin/2-create-an-about-file' have diverged, +and have 1 and 1 different commits each, respectively. + (use "git pull" to merge the remote branch into yours) + +``` + +```bash +git pull +hint: You have divergent branches and need to specify how to reconcile them. +hint: You can do so by running one of the following commands sometime before +hint: your next pull: +hint: +hint: git config pull.rebase false # merge +hint: git config pull.rebase true # rebase +hint: git config pull.ff only # fast-forward only +hint: +hint: You can replace "git config" with "git config --global" to set a default +hint: preference for all repositories. You can also pass --rebase, --no-rebase, +hint: or --ff-only on the command line to override the configured default per +hint: invocation. +fatal: Need to specify how to reconcile divergent branches. + +``` + +```bash +git pull --rebase +Auto-merging about.md +CONFLICT (content): Merge conflict in about.md +error: could not apply 30c4748... start about +hint: Resolve all conflicts manually, mark them as resolved with +hint: "git add/rm ", then run "git rebase --continue". +hint: You can instead skip this commit: run "git rebase --skip". +hint: To abort and get back to the state before "git rebase", run "git rebase --abort". +Could not apply 30c4748... start about + +``` + +```bash +git status +interactive rebase in progress; onto 8ce03aa +Last command done (1 command done): + pick 30c4748 start about +No commands remaining. +You are currently rebasing branch '2-create-an-about-file' on '8ce03aa'. + (fix conflicts and then run "git rebase --continue") + (use "git rebase --skip" to skip this patch) + (use "git rebase --abort" to check out the original branch) + +Unmerged paths: + (use "git restore --staged ..." to unstage) + (use "git add ..." to mark resolution) + both modified: about.md + +no changes added to commit (use "git add" and/or "git commit -a") + +``` + +```bash +nano about.md + +``` + +```bash +git status +interactive rebase in progress; onto 8ce03aa +Last command done (1 command done): + pick 30c4748 start about +No commands remaining. +You are currently rebasing branch '2-create-an-about-file' on '8ce03aa'. + (fix conflicts and then run "git rebase --continue") + (use "git rebase --skip" to skip this patch) + (use "git rebase --abort" to check out the original branch) + +Unmerged paths: + (use "git restore --staged ..." to unstage) + (use "git add ..." to mark resolution) + both modified: about.md + +no changes added to commit (use "git add" and/or "git commit -a") + +``` + +```bash +git add . + +``` + +```bash +git status +interactive rebase in progress; onto 8ce03aa +Last command done (1 command done): + pick 30c4748 start about +No commands remaining. +You are currently rebasing branch '2-create-an-about-file' on '8ce03aa'. + (all conflicts fixed: run "git rebase --continue") + +Changes to be committed: + (use "git restore --staged ..." to unstage) + modified: about.md + + +``` + +```bash +git commit -m 'keep both changes' +[detached HEAD d2f136b] keep both changes + 1 file changed, 2 insertions(+) + +``` + +```bash +git status +interactive rebase in progress; onto 8ce03aa +Last command done (1 command done): + pick 30c4748 start about +No commands remaining. +You are currently editing a commit while rebasing branch '2-create-an-about-file' on '8ce03aa'. + (use "git commit --amend" to amend the current commit) + (use "git rebase --continue" once you are satisfied with your changes) + +nothing to commit, working tree clean + +``` + +```bash +git reabse --continue +git: 'reabse' is not a git command. See 'git --help'. + +The most similar command is + rebase + +``` + +```bash +git rebase --continue +Successfully rebased and updated refs/heads/2-create-an-about-file. + +``` + +```bash +git status +On branch 2-create-an-about-file +Your branch is ahead of 'origin/2-create-an-about-file' by 1 commit. + (use "git push" to publish your local commits) + +nothing to commit, working tree clean + +``` + +```bash +git push +Enumerating objects: 5, done. +Counting objects: 100% (5/5), done. +Delta compression using up to 8 threads +Compressing objects: 100% (2/2), done. +Writing objects: 100% (3/3), 285 bytes | 285.00 KiB/s, done. +Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 +remote: Resolving deltas: 100% (1/1), completed with 1 local object. +To https://github.com/introcompsys/github-inclass-brownsarahm.git + 8ce03aa..d2f136b 2-create-an-about-file -> 2-create-an-about-file + +``` + +```bash +echo "hello world" +hello world + +``` + +```bash +echo "hello world" >> hello.md + +``` + +```bash From e00cc8c5e5ceaa747a3f31b5ed659d34eff79ff3 Mon Sep 17 00:00:00 2001 From: Sarah M Brown Date: Thu, 22 Sep 2022 20:48:29 -0400 Subject: [PATCH 2/3] actual content --- _practice/2022-09-21.md | 0 _prepare/2022-09-21.md | 6 + _review/2022-09-21.md | 4 + notes/2022-09-21.md | 248 ++++++++++++++++++++++++++++------------ 4 files changed, 185 insertions(+), 73 deletions(-) create mode 100644 _practice/2022-09-21.md create mode 100644 _prepare/2022-09-21.md create mode 100644 _review/2022-09-21.md diff --git a/_practice/2022-09-21.md b/_practice/2022-09-21.md new file mode 100644 index 0000000..e69de29 diff --git a/_prepare/2022-09-21.md b/_prepare/2022-09-21.md new file mode 100644 index 0000000..38a1163 --- /dev/null +++ b/_prepare/2022-09-21.md @@ -0,0 +1,6 @@ +1. Read through the Grading Contract README and sample contracts. Start drafting your contract. Bring questions to class on Monday. +1. Bring git questions or scenarios you want to be able to solve to class on Wednesday + +```{warning} +the template contracts in the repo have an error in them; use the ones on the [course website](https://introcompsys.github.io/fall2022/syllabus/contract.html). +``` diff --git a/_review/2022-09-21.md b/_review/2022-09-21.md new file mode 100644 index 0000000..b46cc89 --- /dev/null +++ b/_review/2022-09-21.md @@ -0,0 +1,4 @@ +1. Read today's notes +1. Update your KWL chart with the new items and any learned items. +1. Update the title to any discussion threads you have created to be more descriptive +1. add `branches.md` to your KWL repo and describe how branches work and what things to watch out for in your own words. diff --git a/notes/2022-09-21.md b/notes/2022-09-21.md index 83e102d..63bfb87 100644 --- a/notes/2022-09-21.md +++ b/notes/2022-09-21.md @@ -1,12 +1,18 @@ -# How should I use git in this class +# How should I use git to stay organized this class? ```{warning} -this is currenlty only the raw output from the shell session. Annotation will be added tomorrow +this is currently only the raw output from the shell session. Annotation will be added tomorrow ``` +## How do I work with branches? + +Let's go back to the github iclass repo. ```bash git status +``` + +``` On branch main Your branch is up to date with 'origin/main'. @@ -25,19 +31,34 @@ Untracked files: overview.md setup.py tests/ - typescript no changes added to commit (use "git add" and/or "git commit -a") ``` +I had not pushed my content after Monday, so I have alot of files that are both not staged and fully untracked. + +We do not want to commit direcly to main in general. Working with a branch is better, becuase it gives us more option. + +We can use the `-b` option for git checkout to both create a new branch and switch to it. + ```bash git checkout -b organtzation -Switched to a new branch 'organtzation' +``` +and git replies that it did what we asked. +``` +Switched to a new branch 'organtzation' ``` ```bash git status +``` + +```{note} +Notice that this time in git status it does not compare to origin. this is because the new branch does not have a remote +``` + +``` On branch organtzation Changes not staged for commit: (use "git add ..." to update what will be committed) @@ -54,19 +75,25 @@ Untracked files: overview.md setup.py tests/ - typescript no changes added to commit (use "git add" and/or "git commit -a") ``` +Now + ```bash git add . ``` +we can commit right after staging, since we konw that is what we want. ```bash git commit -m 'from inclass org acitivyt' +``` + +and it will go a bunch of things, beacuse we made a lot of changes. +``` [organtzation 8b62af8] from inclass org acitivyt 23 files changed, 69 insertions(+) create mode 100644 CONTRIBUTING.md @@ -93,24 +120,26 @@ git commit -m 'from inclass org acitivyt' ``` +Once we commit it all, we want to get it to GitHub. + ```bash git push +``` + +``` fatal: The current branch organtzation has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin organtzation - - ``` -```bash -git remote -origin - -``` +and then we can follow what git said to do ```bash git push --set-upstream origin organtzation +``` + +``` Enumerating objects: 11, done. Counting objects: 100% (11/11), done. Delta compression using up to 8 threads @@ -127,15 +156,29 @@ branch 'organtzation' set up to track 'origin/organtzation'. ``` + +## What happens when we start a new branch on GitHub. + +Create a branch from an issue: + + + ```bash git fetch +``` +this step dowloads the content that is on the new branch +``` From https://github.com/introcompsys/github-inclass-brownsarahm * [new branch] 2-create-an-about-file -> origin/2-create-an-about-file ``` +we use git satus to see what else it did ```bash git status +``` + +``` On branch organtzation Your branch is up to date with 'origin/organtzation'. @@ -143,19 +186,35 @@ nothing to commit, working tree clean ``` +and see that it did not change our local status, or location. + ```bash git branch +``` + +``` main * organtzation ``` +but we can see the new branch isn not even in our local repo, though it has been fetched. +SO we should checkout ```bash git checkout 2-create-an-about-file +``` + +``` branch '2-create-an-about-file' set up to track 'origin/2-create-an-about-file'. Switched to a new branch '2-create-an-about-file' ``` +this did a few things. It switched our local repference point, made our local directory match the remote branch, and it set the new branch to track the origin branch. + + +## What if we edit the file in two places? + +First, we edit the file locally ```bash echo "test" >> about.md @@ -164,6 +223,9 @@ echo "test" >> about.md ```bash git status +``` + +``` On branch 2-create-an-about-file Your branch is up to date with 'origin/2-create-an-about-file'. @@ -179,32 +241,35 @@ no changes added to commit (use "git add" and/or "git commit -a") ```bash cat about.md test - ``` +and add and commit the changes + ```bash git add . - ``` -```bash -git comit -m 'start about' -git: 'comit' is not a git command. See 'git --help'. - -The most similar command is - commit - -``` ```bash git commit -m 'start about' +``` + +``` [2-create-an-about-file 30c4748] start about 1 file changed, 1 insertion(+) - ``` +Then edit the file in your browser. + + + +Now we can try to push it from the local copy + ```bash git push +``` + +``` To https://github.com/introcompsys/github-inclass-brownsarahm.git ! [rejected] 2-create-an-about-file -> 2-create-an-about-file (fetch first) error: failed to push some refs to 'https://github.com/introcompsys/github-inclass-brownsarahm.git' @@ -215,51 +280,17 @@ hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. ``` +We can't push because we ahve a merge conflict. -```bash -git fetch -remote: Enumerating objects: 5, done. -remote: Counting objects: 100% (5/5), done. -remote: Compressing objects: 100% (2/2), done. -remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 -Unpacking objects: 100% (3/3), 643 bytes | 214.00 KiB/s, done. -From https://github.com/introcompsys/github-inclass-brownsarahm - 3c9980a..8ce03aa 2-create-an-about-file -> origin/2-create-an-about-file - -``` +So first, we have to pull ```bash -cat about.md -test - -``` - -```bash -ls -a -. .git README.md -.. .github about.md - -``` - -```bash -ls .git -COMMIT_EDITMSG config index objects -FETCH_HEAD description info packed-refs -HEAD hooks logs refs - +git pull ``` -```bash -git checkout 2-create-an-about-file -Already on '2-create-an-about-file' -Your branch and 'origin/2-create-an-about-file' have diverged, -and have 1 and 1 different commits each, respectively. - (use "git pull" to merge the remote branch into yours) +Now it tells us more about the merge conflict. ``` - -```bash -git pull hint: You have divergent branches and need to specify how to reconcile them. hint: You can do so by running one of the following commands sometime before hint: your next pull: @@ -273,11 +304,15 @@ hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation. fatal: Need to specify how to reconcile divergent branches. - ``` +We can try the rebase option. We'll talk more about how this works in detail later, but it basically tries to undo one set of commits, apply the others then apply the first set on top. If it cannot, then there's still a conflict. + ```bash git pull --rebase +``` + +``` Auto-merging about.md CONFLICT (content): Merge conflict in about.md error: could not apply 30c4748... start about @@ -286,9 +321,11 @@ hint: "git add/rm ", then run "git rebase --continue". hint: You can instead skip this commit: run "git rebase --skip". hint: To abort and get back to the state before "git rebase", run "git rebase --abort". Could not apply 30c4748... start about - ``` +And we cannot, so we have more to do. + + ```bash git status interactive rebase in progress; onto 8ce03aa @@ -309,13 +346,42 @@ no changes added to commit (use "git add" and/or "git commit -a") ``` +We will use [nano](https://www.nano-editor.org/) to edit. + ```bash nano about.md +``` + + +### Resolving a Merge conflict ``` +>>>>>>> HEAD +test +======== +I am a Professor +<<<<<<<< 30c4748 +``` + +Notes: +- HEAD is the current directory's content +- the other branch is indicated by its last commit number + + +To fix it, we manually edit the file for it to be what we want + +``` +test +I am a Professor +``` + +Then we can finish resoling ```bash git status +``` + +``` interactive rebase in progress; onto 8ce03aa Last command done (1 command done): pick 30c4748 start about @@ -334,6 +400,7 @@ no changes added to commit (use "git add" and/or "git commit -a") ``` +we add and commit: ```bash git add . @@ -341,6 +408,10 @@ git add . ```bash git status + +``` + +``` interactive rebase in progress; onto 8ce03aa Last command done (1 command done): pick 30c4748 start about @@ -357,6 +428,9 @@ Changes to be committed: ```bash git commit -m 'keep both changes' +``` + +``` [detached HEAD d2f136b] keep both changes 1 file changed, 2 insertions(+) @@ -364,6 +438,9 @@ git commit -m 'keep both changes' ```bash git status +``` + +``` interactive rebase in progress; onto 8ce03aa Last command done (1 command done): pick 30c4748 start about @@ -376,23 +453,24 @@ nothing to commit, working tree clean ``` -```bash -git reabse --continue -git: 'reabse' is not a git command. See 'git --help'. +but after that, it still says that it is in the interactive rebase mode, because there is one final step to do. -The most similar command is - rebase - -``` ```bash git rebase --continue -Successfully rebased and updated refs/heads/2-create-an-about-file. ``` +``` +Successfully rebased and updated refs/heads/2-create-an-about-file. + +``` +and finally ```bash git status +``` + +``` On branch 2-create-an-about-file Your branch is ahead of 'origin/2-create-an-about-file' by 1 commit. (use "git push" to publish your local commits) @@ -400,7 +478,7 @@ Your branch is ahead of 'origin/2-create-an-about-file' by 1 commit. nothing to commit, working tree clean ``` - +we see it is all set and ready to go. ```bash git push Enumerating objects: 5, done. @@ -415,6 +493,10 @@ To https://github.com/introcompsys/github-inclass-brownsarahm.git ``` +and indeed the push works! + +## A note on echo + ```bash echo "hello world" hello world @@ -426,4 +508,24 @@ echo "hello world" >> hello.md ``` -```bash +## Review today's class + + +```{include} ../_review/2022-09-21.md +``` + +## Prepare for Next Class + +```{note} +This is what is required, before the next class and will be checked or if you +don't do it you will have trouble participating in class +``` + +```{include} ../_practice/2022-09-21.md +``` + + + +## More Practice +```{include} ../_practice/2022-09-21.md +``` From 3f49f0e2783330f4391826777c39c6d87d31f76e Mon Sep 17 00:00:00 2001 From: Sarah M Brown Date: Thu, 22 Sep 2022 21:03:12 -0400 Subject: [PATCH 3/3] headings fix --- _practice/2022-09-21.md | 1 + _review/2022-09-19.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/_practice/2022-09-21.md b/_practice/2022-09-21.md index e69de29..60feb6a 100644 --- a/_practice/2022-09-21.md +++ b/_practice/2022-09-21.md @@ -0,0 +1 @@ +1. Try creating a merge conflict and resolving it using your favorite IDE. diff --git a/_review/2022-09-19.md b/_review/2022-09-19.md index 467c65a..e8424e2 100644 --- a/_review/2022-09-19.md +++ b/_review/2022-09-19.md @@ -4,11 +4,12 @@ 1. Review past classes activities (eg via the activities section on the left) and catchup if appropriate -### Terminal File moving reflection + Start with a file explorer open, but then try to close it and use only command line tools to explore and make your choices ```markdown +### Terminal File moving reflection 1. Did this get easier toward the end? 1. Use the history to see which commands you used and how many times each, make a table below. 1. Did you have to look up how to do anything we had not done in class?