adding a remote when created locally¶
Last class we created tiny-book a jupyter-book. We’ll pick up there.
First, let’s review the contents
ls_build logo.png references.bib
_config.yml markdown-notebooks.md requirements.txt
_toc.yml markdown.md
intro.md notebooks.ipynband make sure everything is okay with git:
git statusOn branch main
nothing to commit, working tree cleanHint
Compare it to some previous examples:
Hint
We saw something similar a branch we made locally and note what happened when we tried to push
Let’s try git push
git pushfatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using
git remote add <name> <url>
and then push using the remote name
git push <name>This is similar to when we a branch we made locally and tried to push, but this time, we have to create the remote.
Let’s investigate a bit further:
ls .git/COMMIT_EDITMSG description hooks info objects
config HEAD index logs refswe have not yet looked at the config file.
let’s look now
cat .git/config[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = truegit stores all of the important information for the program to know how to interpret the storage of the git objects.
Now, we create a repo on github in browser[1] and copy its url and then use the command like the error message above instructed. This repo is compeltely empty, it includes these instructions too.
git remote add origin https://github.com/compsys-progtools/tiny-book-brownsarahm-2.gitNow, if we use git remote with no subcommand, it lists the remote we just created!
git remoteoriginand with -v it shows us the full url
git remote -vorigin https://github.com/compsys-progtools/tiny-book-brownsarahm-2.git (fetch)
origin https://github.com/compsys-progtools/tiny-book-brownsarahm-2.git (push)now, let’s try push again
git pushfatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.Let’s see what changed in the config
cat .git/config[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/compsys-progtools/tiny-book-brownsarahm-2.git
fetch = +refs/heads/*:refs/remotes/origin/*We’ll use the shortcut for the --set-upstream option, -u that we found in the help (and a tip for from the github repo)
git push -u origin mainEnumerating objects: 14, done.
Counting objects: 100% (14/14), done.
Delta compression using up to 16 threads
Compressing objects: 100% (12/12), done.
Writing objects: 100% (14/14), 16.45 KiB | 16.45 MiB/s, done.
Total 14 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/compsys-progtools/tiny-book-brownsarahm-2.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.ls_build logo.png references.bib
_config.yml markdown-notebooks.md requirements.txt
_toc.yml markdown.md
intro.md notebooks.ipynblet’s edit the config
nano _config.ymlwe’ll set our names as the author
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32# Book settings # Learn more at https://jupyterbook.org/customize/config.html title: My Tiny Book author: Sarah M Brown logo: logo.png # Force re-execution of notebooks on each build. # See https://jupyterbook.org/content/execute.html execute: execute_notebooks: force # Define the name of the latex output file for PDF builds latex: latex_documents: targetname: book.tex # Add a bibtex file so that we can create citations bibtex_bibfiles: - references.bib # Information about where the book exists on the web repository: url: https://github.com/executablebooks/jupyter-book # Online location of your book path_to_book: docs # Optional path to your book, relative to the repository root branch: master # Which branch of the repository should be used when creating links (optional) # Add GitHub buttons to your book # See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository html: use_issues_button: true use_repository_button: true
Now we can re-build to get the change to show in the html
jupyter-book build .Running Jupyter-Book v1.0.4.post1
Source Folder: /Users/brownsarahm/Documents/inclass/systems/tiny-book
Config Path: /Users/brownsarahm/Documents/inclass/systems/tiny-book/_config.yml
Output Path: /Users/brownsarahm/Documents/inclass/systems/tiny-book/_build/html
Running Sphinx v7.4.7
loading translations [en]... done
[etoc] Changing master_doc to 'intro'
loading pickled environment... checking bibtex cache... up to date
done
myst v3.0.1: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions={'dollarmath', 'colon_fence', 'linkify', 'tasklist', 'substitution'}, disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('mailto', 'http', 'https'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
myst-nb v1.3.0: NbParserConfig(custom_formats={}, metadata_key='mystnb', cell_metadata_key='mystnb', kernel_rgx_aliases={}, eval_name_regex='^[a-zA-Z_][a-zA-Z0-9_]*$', execution_mode='force', execution_cache_path='', execution_excludepatterns=[], execution_timeout=30, execution_in_temp=False, execution_allow_errors=False, execution_raise_on_error=False, execution_show_tb=False, merge_streams=False, render_plugin='default', remove_code_source=False, remove_code_outputs=False, scroll_outputs=False, code_prompt_show='Show code cell {type}', code_prompt_hide='Hide code cell {type}', number_source_lines=False, output_stderr='show', render_text_lexer='myst-ansi', render_error_lexer='ipythontb', render_image_options={}, render_figure_options={}, render_markdown_format='commonmark', output_folder='build', append_css=True, metadata_to_fm=False)
Using jupyter-cache at: /Users/brownsarahm/Documents/inclass/systems/tiny-book/_build/.jupyter_cache
sphinx-multitoc-numbering v0.1.3: Loaded
building [mo]: targets for 0 po files that are out of date
writing output...
building [html]: targets for 4 source files that are out of date
updating environment: [config changed ('author')] 4 added, 0 changed, 0 removed
/Users/brownsarahm/Documents/inclass/systems/tiny-book/markdown-notebooks.md: Executing notebook using local CWD [mystnb]
/Users/brownsarahm/Documents/inclass/systems/tiny-book/markdown-notebooks.md: Executed notebook in 0.83 seconds [mystnb]
/Users/brownsarahm/Documents/inclass/systems/tiny-book/notebooks.ipynb: Executing notebook using local CWD [mystnb]
/Users/brownsarahm/Documents/inclass/systems/tiny-book/notebooks.ipynb: Executed notebook in 1.23 seconds [mystnb]
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
copying assets...
copying static files... done
copying extra files... done
copying assets: done
writing output... [100%] notebooks
generating indices... genindex done
writing additional pages... search done
copying images... [100%] _build/jupyter_execute/6dd0cd1655c6de15b65fe5aad8eab28fe9f845bcf6100d0fc4a46c2ae73d29f2.png
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.
The HTML pages are in _build/html.
===============================================================================
Finished generating HTML for book.
Your book's HTML pages are here:
_build/html/
You can look at your book by opening this file in a browser:
_build/html/index.html
Or paste this line directly into your browser bar:
file:///Users/brownsarahm/Documents/inclass/systems/tiny-book/_build/html/index.html
===============================================================================Make a repo that you are the owner of and add that too:
git remote add personal https://github.com/brownsarahm/tiny-book.gitwe can have multiple remotes. Think about how these relate to the
git remoteorigin
personalgit remote -vorigin https://github.com/compsys-progtools/tiny-book-brownsarahm-2.git (fetch)
origin https://github.com/compsys-progtools/tiny-book-brownsarahm-2.git (push)
personal https://github.com/brownsarahm/tiny-book.git (fetch)
personal https://github.com/brownsarahm/tiny-book.git (push)and it stores them both in the config:
cat .git/config[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/compsys-progtools/tiny-book-brownsarahm-2.git
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "personal"]
url = https://github.com/brownsarahm/tiny-book.git
fetch = +refs/heads/*:refs/remotes/personal/*What else can git tell me?¶
Let’s start in the gh inclass reop
cd ../gh-inclass-sp26-brownsarahm/git statusOn branch main
Your branch is ahead of 'origin/main' by 3 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree cleanwe can get an idea of hwat those commits contain with the log
git log -n 3 --pretty=onelinecbdb5fc52d22037f51eeac8cb533c0b526789ba8 (HEAD -> main, origin/organize, organize) remove extra >
d1c1df80396c1eb7f395dad955f83f6dd995861e start organizing
219c49c573315e67e15c080f0c03271bbb7a8cd2 add title to readme-nlimits the number
git diff gives us more details about the chnges over a set of commits (or other points... we’ll see later)
git diff 219c..cbdb README.mddiff --git a/README.md b/README.md
index 1ec17bc..49e94cc 100644
diff --git a/README.md b/README.md
index 1ec17bc..49e94cc 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,21 @@
[](https://classroom.github.com/open-in-codespaces?assignment_repo_id=22432670)
# Readme
+|file | contents |
+| --| -- |
+| abstract_base_class.py | core abstract classes for the project |
+| helper_functions.py | utitly funtions that are called by many classes |
+| important_classes.py | classes that inherit from the abc |
+| alternative_classes.py | classes that inherit from the abc |
+| LICENSE.md | the info on how the code can be reused|
+| CONTRIBUTING.md | instructions for how people can contribute to the project|
+| setup.py | file with function with instructions for pip |
+| test_abc.py | tests for constructors and methods in abstract_base_class.py|
+| tests_helpers.py | tests for constructors and methods in helper_functions.py|
+| tests_imp.py | tests for constructors and methods in important_classes.py|
+| tests_alt.py | tests for constructors and methods in alternative_classes.py|
+| API.md | jupyterbook file to generate api documentation |
+| _config.yml | jupyterbook config for documentation |
+| _toc.yml | jupyter book toc file for documentation |
+| philosophy.md | overview of how the code is organized for docs |
+| example.md | myst notebook example of using the code |
+| scratch.ipynb | jupyter notebook from dev |now let’s edit the file:
nano README.md1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24[](https://classroom.github.com/open-in-codespaces?assignment_repo_id=22432670) # Readme this repo contains the files as below |file | contents | | --| -- | | abstract_base_class.py | core abstract classes for the project | | helper_functions.py | utitly funtions that are called by many classes | | important_classes.py | classes that inherit from the abc | | alternative_classes.py | classes that inherit from the abc | | LICENSE.md | the info on how the code can be reused| | CONTRIBUTING.md | instructions for how people can contribute to the project| | setup.py | file with function with instructions for pip | | test_abc.py | tests for constructors and methods in abstract_base_class.py| | tests_helpers.py | tests for constructors and methods in helper_functions.py| | tests_imp.py | tests for constructors and methods in important_classes.py| | tests_alt.py | tests for constructors and methods in alternative_classes.py| | API.md | jupyterbook file to generate api documentation | | _config.yml | jupyterbook config for documentation | | _toc.yml | jupyter book toc file for documentation | | philosophy.md | overview of how the code is organized for docs | | example.md | myst notebook example of using the code | | scratch.ipynb | jupyter notebook from dev |
We can use git diff with no references to compare the last commit to the current working directory. This can be helpful when you’re planning your commit message.
git diffdiff --git a/README.md b/README.md
index 49e94cc..da455ad 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
[](https://classroom.github.com/open-in-codespaces?assignment_repo_id=22432670)
# Readme
+
+this repo contains the files as below
+
|file | contents |
| --| -- |
| abstract_base_class.py | core abstract classes for the project |git statusOn branch main
Your branch is ahead of 'origin/main' by 3 commits.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")git commit -a -m 'describe table'[main 694223d] describe table
1 file changed, 3 insertions(+)What about goign backwards¶
git revert lets use add a new commit that contains the opposite changes of the commit that we want to revert.
For example, my commit 694223d adds the table description, so reverting will remove it.
git revert 694223d[main ccbb750] Revert "describe table"
1 file changed, 3 deletions(-)notice there is a new commit with the revert:
git log -n 5 --pretty=onelineccbb75084ba081ba5ad1dd16349315ca268157a0 (HEAD -> main) Revert "describe table"
694223d2741c9bb24ee0ac2abc5934be80429614 describe table
cbdb5fc52d22037f51eeac8cb533c0b526789ba8 (origin/organize, organize) remove extra >
d1c1df80396c1eb7f395dad955f83f6dd995861e start organizing
219c49c573315e67e15c080f0c03271bbb7a8cd2 add title to readmeand the file is as before
cat README.md[](https://classroom.github.com/open-in-codespaces?assignment_repo_id=22432670)
# Readme
|file | contents |
| --| -- |
| abstract_base_class.py | core abstract classes for the project |
| helper_functions.py | utitly funtions that are called by many classes |
| important_classes.py | classes that inherit from the abc |
| alternative_classes.py | classes that inherit from the abc |
| LICENSE.md | the info on how the code can be reused|
| CONTRIBUTING.md | instructions for how people can contribute to the project|
| setup.py | file with function with instructions for pip |
| test_abc.py | tests for constructors and methods in abstract_base_class.py|
| tests_helpers.py | tests for constructors and methods in helper_functions.py|
| tests_imp.py | tests for constructors and methods in important_classes.py|
| tests_alt.py | tests for constructors and methods in alternative_classes.py|
| API.md | jupyterbook file to generate api documentation |
| _config.yml | jupyterbook config for documentation |
| _toc.yml | jupyter book toc file for documentation |
| philosophy.md | overview of how the code is organized for docs |
| example.md | myst notebook example of using the code |
| scratch.ipynb | jupyter notebook from dev |git config --helpgit log -n 10 --pretty=onelineccbb75084ba081ba5ad1dd16349315ca268157a0 (HEAD -> main) Revert "describe table"
694223d2741c9bb24ee0ac2abc5934be80429614 describe table
cbdb5fc52d22037f51eeac8cb533c0b526789ba8 (origin/organize, organize) remove extra >
d1c1df80396c1eb7f395dad955f83f6dd995861e start organizing
219c49c573315e67e15c080f0c03271bbb7a8cd2 add title to readme
ba7a1e6b5fbd737d7ecb2cd54e32866121a476aa (origin/main, origin/HEAD) Merge pull request #6 from compsys-progtools/organizing_ac
ce430e9745738c4b8818e2d527d303ca1b5d0f9e (origin/organizing_ac) add files for organizing activity
f6886babaa283a8238632930bf2cca9121fc274b (my_branch_checkedoutb, my_branch) Merge pull request #5 from compsys-progtools/2-create-an-about-file
cfd464dc22568fcff6aa302fbd6025e44b7262ac (origin/2-create-an-about-file, 2-create-an-about-file) Update about.md
a254c24301bc02c9624726573e902c8ffe437a0b create empty aboutcd ..lsdemo kwl-sp26-brownsarahm
gh-inclass-sp26-brownsarahm tiny-bookwe can allos check out specific commits
git checkout cbdbNote: switching to 'cbdb'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at cbdb5fc remove extra >Other reerences¶
We have seen that branches are pointers to commits that move. Tags are pointers to commits that do not move:
git tag v1git checkout mainPrevious HEAD position was cbdb5fc remove extra >
Switched to branch 'main'
Your branch is ahead of 'origin/main' by 5 commits.
(use "git push" to publish your local commits)git log -n 10 --pretty=onelineccbb75084ba081ba5ad1dd16349315ca268157a0 (HEAD -> main) Revert "describe table"
694223d2741c9bb24ee0ac2abc5934be80429614 describe table
cbdb5fc52d22037f51eeac8cb533c0b526789ba8 (tag: v1, origin/organize, organize) remove extra >
d1c1df80396c1eb7f395dad955f83f6dd995861e start organizing
219c49c573315e67e15c080f0c03271bbb7a8cd2 add title to readme
ba7a1e6b5fbd737d7ecb2cd54e32866121a476aa (origin/main, origin/HEAD) Merge pull request #6 from compsys-progtools/organizing_ac
ce430e9745738c4b8818e2d527d303ca1b5d0f9e (origin/organizing_ac) add files for organizing activity
f6886babaa283a8238632930bf2cca9121fc274b (my_branch_checkedoutb, my_branch) Merge pull request #5 from compsys-progtools/2-create-an-about-file
cfd464dc22568fcff6aa302fbd6025e44b7262ac (origin/2-create-an-about-file, 2-create-an-about-file) Update about.md
a254c24301bc02c9624726573e902c8ffe437a0b create empty aboutTags have to be pushed (and pulled) explicitly
git push --tagsTotal 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://github.com/compsys-progtools/gh-inclass-sp26-brownsarahm.git
* [new tag] v1 -> v1Prepare for Next Class¶
Quiz yourself to be sure you remember the following:
what parts of git are like pointers?
what does the
git statuscommand do (in detail, what files does it read, what does it compare, etc)What file stores information for git and lives outside of the .git directory?
what are the parts of a commit?
what is the staging area?
what are the types of git ojbects?
what does
>do ingit status > curgit? what is the risk of this command?what does
|do in your getassignment action in your kwl repo?what is the role of a hash in git objects?
how can we view git objects’ content?
In particular, review the following class sessions
https://
compsys -progtools .github .io /spring2026 /notes /2026 -02 -10/ https://
compsys -progtools .github .io /spring2026 /notes /2026 -02 -17/
create a midsemreview.md with your answers to the questions.
Badges¶
Review the notes from today
Use git bisect to find the first bad commit in the toy bug repo, save the command history and the bad commit hash to git_debug.md
Determine how many of the tags in the course website are annotated vs lightweight using (hint: annotated are objects, lightweight just point to commits). (You may need to use
git pull --tagsin your clone of the course website)
# Tags
<!-- short defintion/description in your own words of what a tag is and what it is for -->
## Comparing tag types
<!-- include your experiment terminal history and interpretation -->
## Inspecting tags
Course website tags by type:
- annoted:
- lightweight:
<!-- include lists of tags for each type -->build idea create tool that can automatically generate a set of files, and make commits, including one that is the “error”, so that each student could run a local command and get a repo with the error at a different point, for a more personalized version of the toy bug exercise.
Review the notes from today
Use git bisect to find the first bad commit in the toy bug repo, save the command history and the bad commit hash to git_debug.md
Determine how many of the tags in the course website are annotated vs lightweight using (hint: annotated are objects, lightweight just point to commits). (You may need to use
git pull --tagsin your clone of the course website)
# Tags
<!-- short defintion/description in your own words of what a tag is and what it is for -->
## Comparing tag types
<!-- include your experiment terminal history and interpretation -->
## Inspecting tags
Course website tags by type:
- annoted:
- lightweight:
<!-- include lists of tags for each type -->Experience Report Evidence¶
Questions After Today’s Class¶
get the link to create your repo from prismia, accept assignment