An extra short post this week. Not something Lynn will be doing, but I wanted to document things for myself.

Last post I sorted getting multiple GitHub accounts working on my development system. Currently my own GitHub account and now also Lynn’s account. As things stand, a copy of Lynn’s blog posts and related files has not been pushed to his account. Though the repo for that has been created, lb_dbls.

Update Lynn’s GitHub Repo

I was going to fork my hb_dbls repo into the directory I used to test accessing Lynn’s GitHub account, lb_dbls. And then push it to the repo on Lynn’s GitHub account. But in the end figured it would probably be faster and simpler to just copy the local directory (hbdsLynn, minus the .git directory and .gitignore) of my repo to the new directory for Lynn’s account. Then push that to GitHub.

The copying will include all the Hugo and Netlify stuff as well. And some other directories I use for various purposes. But a lot of that will not get pushed to GitHub. The .gitignore in Lynn’s repo will make sure of that.

I didn’t want to mess up the lb_dbls repo, so I decided to test this using another directory. The destination directory must exist for the following approach to work correctly.

New-Item -ItemType Directory -Path r:\hugo\rekTst
Copy-Item -Path (Get-ChildItem -Path "r:\hugo\hbdsLynn" -Exclude @('.git', '.gitignore')).FullName -Destination r:\hugo\rekTst -Recurse -Force

That seemed to work as desired. So let’s use the correct repo directory.

Copy-Item -Path (Get-ChildItem -Path "r:\hugo\hbdsLynn" -Exclude @('.git', '.gitignore')).FullName -Destination r:\hugo\lb_dbls -Recurse -Force

Let’s compare the two directories.

PS R:\hugo\lb_dbls> $hdbs = Get-ChildItem -Recurse -path r:\hugo\hbdsLynn
PS R:\hugo\lb_dbls> $lb_dbls = Get-ChildItem -Recurse -path r:\hugo\lb_dbls
PS R:\hugo\lb_dbls> Compare-Object -ReferenceObject $hdbs -DifferenceObject $lb_dbls

InputObject            SideIndicator
-----------            -------------
lb_dbls.code-workspace =>

Looks like they are the same. At least based on directory and file names.

Next I started Hugo locally to test.

PS R:\hugo\lb_dbls> e:\appWeb\hugo\hugo server -D -F
Watching for changes in R:\hugo\lb_dbls\{archetypes,content,data,layouts,static,themes}
Watching for config changes in R:\hugo\lb_dbls\config.toml
Start building sites …
hugo v0.119.0-b84644c008e0dc2c4b67bd69cccf87a41a03937e+extended windows/amd64 BuildDate=2023-09-24T15:20:17Z VendorInfo=gohugoio


                   | EN
-------------------+-----
  Pages            | 59
  Paginator pages  | 11
  Non-page files   | 56
  Static files     | 10
  Processed images |  0
  Aliases          | 16
  Sitemaps         |  1
  Cleaned          |  0

Built in 119 ms
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at //localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Opened it in the browser and things seem to be just fine. Okay let’s try pushing to Lynn’s remote repo on GitHub.

PS R:\hugo\lb_dbls> git st
On branch main

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        README.md
        archetypes/
        cfg_lynn_X_ca_prod.toml
        cfg_lynn_X_ca_prod.toml
        cfg_netlify.toml
        config.toml
        content/
        layouts/
        netlffy.toml
        rek_play/
        static/

nothing added to commit but untracked files present (use "git add" to track)
PS R:\hugo\lb_dbls> git add .
PS R:\hugo\lb_dbls> git st
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   README.md
        new file:   archetypes/default.md
        new file:   cfg_lynn_X_ca_prod.toml
        new file:   cfg_lynn_X_ca_prod.toml
        new file:   cfg_netlify.toml
        new file:   config.toml
        new file:   content/post/back_wall/img/backwall_650a.png
        new file:   content/post/back_wall/img/backwall_650b.png
        new file:   content/post/back_wall/img/backwall_650c.png
        new file:   content/post/back_wall/img/backwall_650d.png
        new file:   content/post/back_wall/index.md
        new file:   content/post/bit_of_history/index.md
        ... snip ...
        new file:   static/css/custom.css
        new file:   static/favicon.ico

PS R:\hugo\lb_dbls> git cm "chore: push copy of Lynn's blog to his GitHub remote repo" -m "moving project from my github account to Lynn's" -m "I will use Lynn's account to update the blog"
[main b465a2b] chore: push copy of Lynn's blog to his GitHub remote repo
 106 files changed, 3132 insertions(+)
 create mode 100644 README.md
 create mode 100644 archetypes/default.md
 create mode 100644 cfg_lynn_b_ca_prod.toml
 create mode 100644 cfg_lynn_k_ca_prod.toml
 create mode 100644 cfg_netlify.toml
 create mode 100644 config.toml
 create mode 100644 content/post/back_wall/img/backwall_650a.png
 create mode 100644 content/post/back_wall/img/backwall_650b.png
 create mode 100644 content/post/back_wall/img/backwall_650c.png
 create mode 100644 content/post/back_wall/img/backwall_650d.png
 create mode 100644 content/post/back_wall/index.md
 create mode 100644 content/post/bit_of_history/index.md
 ... snip ...
 create mode 100644 static/css/custom.css
 create mode 100644 static/favicon.ico

PS R:\hugo\lb_dbls> git p
Enumerating objects: 158, done.
Counting objects: 100% (158/158), done.
Delta compression using up to 16 threads
Compressing objects: 100% (144/144), done.
Writing objects: 100% (157/157), 402.88 KiB | 1.22 MiB/s, done.
Total 157 (delta 8), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (8/8), done.
To github-lb:L###/lb_dbls.git
   7b2f6a1..b465a2b  main -> main

And, that should be that. From now on I will work in/with the lb_dbls directory/repo.

Change of Mind

With the above, the repo lost all of its previous git history. At first didn’t think that would matter. But in the end have decided that the complete history might prove of interest to Lynn at some time in the future. So, deleted the remote repository on GitHub and created it again (empty repository).

I then deleted the .git directory—except for config—in the local repo (lb_dbls). Then copied over everything–except config–from the original repository I had created (hbdsLynn).

Quick local server with Hugo says the site still works as expected (which of course was expected as I didn’t change any of the content).

Okay let’s have a look at the history.

PS R:\hugo\lb_dbls> git log
Author: tooOld2Code <62121320+XXX@users.noreply.github.com>
Date:   Tue Sep 26 13:37:20 2023 -0700

    fix: add new directory to .gitignore

    add new hugo config file to work with broman.ca

    date fix on a post, isometric_pyramid

commit 501f1243fb5bbaeb02ee089edadc33dcbfb6b63b
Author: tooOld2Code <62121320+XXX@users.noreply.github.com>
Date:   Wed Sep 20 15:32:58 2023 -0700

    fix: update post based on editorial discussions

    remove the single isometric image, adjust wording to account for that change

    add note regarding boasts
... ...

And, that matches the history on the original repository. So, will commit couple minor edits and push to Lynn’s repository.

PS R:\hugo\lb_dbls> git add .
PS R:\hugo\lb_dbls> git cm "chore: push copy of Lynn's blog to his GitHub remote repo" -m "moving project from my github account to Lynn's" -m "I will use Lynn's account to update the blog" -m "modify .gitignore and README.md"
[main b5a96a8] chore: push copy of Lynn's blog to his GitHub remote repo
 2 files changed, 7 insertions(+)
PS R:\hugo\lb_dbls> git p
Enumerating objects: 718, done.
Counting objects: 100% (718/718), done.
Delta compression using up to 16 threads
Compressing objects: 100% (606/606), done.
Writing objects: 100% (718/718), 563.17 KiB | 1.02 MiB/s, done.
Total 718 (delta 272), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (272/272), done.
To github-lb:L###/lb_dbls.git
 * [new branch]      main -> main

And checking the repository on GitHub everything looks as expected, including file histories.

Resources

  • [Get-ChildItem]https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-7.3)
  • Copy-Item and exclude folders
  • Easily Compare Two Folders by Using PowerShell