technical:notes_cherrytree_git_sync

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
technical:notes_cherrytree_git_sync [2025/05/15 04:48] super_stundertechnical:notes_cherrytree_git_sync [2025/05/27 18:44] (current) super_stunder
Line 1: Line 1:
-FIXME+====== Using Git to sync CherryTree notes between systems ====== 
 +As much as I love posting information and stories to this site for others to consume there are other things I don't want put out on the web like my personal journal.  Not like there is anything "bad" in there its just boring stuff I don't think most people would be interested in.  I like to keep these notes in [[https://www.giuspen.net/cherrytree/|CherryTree]].  As it says in the official repo "A hierarchical note taking application, featuring rich text and syntax highlighting, storing data in either a single file (xml or sqlite) or multiple files and directories."
  
-cd ~/Documents/CherryTree_Docs/+I have used the application on Windows for keeping track of my projects at work and other one offs.  I was really bad about just keeping things in notepad and after a while looked for alternatives.  Spent a little bit of time with notepad++ but ended up pretty happy with CherryTree and I have used it ever since.
  
-git init+{{ :technical:screenshot_from_2025-05-27_09-15-19.png?nolink&400 |}}
  
-git status+The one feature CherryTree is missing is the ability to sync between different host.  I am not trying to sync things between teams of people or anything I just want to sync my own notes between my own devices.   Well it looks like this is another job for my personal [[hosting_your_own_git|git repos]].   
 + 
 +Alright I explained enough about the git repo setup on the host your own git page, in the case of CherryTree I am not going to use the repos directory.  I had already started saving CherryTree notes to a folder under my home documents called "CherryTree_Docs" When saving files in CherryTree they aren't saved as raw text files you can save them in a SQLite file or in XML format.   
 + 
 +{{ :technical:screenshot_from_2025-05-27_09-59-08.png?nolink |}} 
 + 
 +I saved my documents as SQLite before I started this whole process.  These files are in binary database type format which so far is working when I push/pull from the git repo, but If I had to do it again I may go with XML format for the git merging possibilities.  I am going to stick with the SQLite for now and will update this if I ever decide to change. 
 + 
 +** Step 1: Initialize the repository from the directory you save CherryTree files in ** 
 +<code> 
 +nugget@tiptop:~$ cd ~/Documents/CherryTree_Docs/ 
 +nugget@tiptop:~/Documents/CherryTree_Docs/ git init 
 +nugget@tiptop:~/Documents/CherryTree_Docs/ git status
  
 On branch main On branch main
Line 25: Line 38:
  
 nothing added to commit but untracked files present (use "git add" to track) nothing added to commit but untracked files present (use "git add" to track)
-eric@kalin-emcwilliams:~/Documents/CherryTree_Docs$ git add -A + 
-eric@kalin-emcwilliams:~/Documents/CherryTree_Docs$ git status+nugget@tiptop:~/Documents/CherryTree_Docs$ git add -A 
 +nugget@tiptop:~/Documents/CherryTree_Docs$ git status
 On branch main On branch main
  
Line 46: Line 60:
  new file:   Kaiser_IT_Planning.ctb~~~  new file:   Kaiser_IT_Planning.ctb~~~
  
-eric@kalin-emcwilliams:~/Documents/CherryTree_Docs$ git commit -m "Initialize repository"+nugget@tiptop:~/Documents/CherryTree_Docs$ git commit -m "Initialize repository"
  
 [main (root-commit) 1c6be2f] Initialize repository [main (root-commit) 1c6be2f] Initialize repository
Line 62: Line 76:
  create mode 100644 Kaiser_IT_Planning.ctb~~  create mode 100644 Kaiser_IT_Planning.ctb~~
  create mode 100644 Kaiser_IT_Planning.ctb~~~  create mode 100644 Kaiser_IT_Planning.ctb~~~
-eric@kalin-emcwilliams:~/Documents/CherryTree_Docs$ +nugget@tiptop:~/Documents/CherryTree_Docs$  
 +</code>
  
 +As you may notice CherryTree has some of its own versioning/roll back methods.  I believe this is done by naming files with the ctb extension then adding the tilde ~, ~~, ~~~ I haven't had to dig that far into it yet but I this seems to be the logic from some of my brief reading. 
 +
 +** Step 2: Building a bare repo on your git server ** 
  
 SSH to your remote host and setup the bare repo: (this is assuming you have the right accounts and sshkeys setup) SSH to your remote host and setup the bare repo: (this is assuming you have the right accounts and sshkeys setup)
-ssh eric@gitshed.igazine.com 
  
-mkdir -p git/cherrytree.git +<code> 
-git init --bare git/cherrytree.git+nugget@tiptop:~$ ssh nugget@gitshed.igazine.com 
 +Last login: Tue May 27 15:18:33 2025 from 127.0.0.1 
 +nugget@gitshed:~$ mkdir -p git/cherrytree.git 
 +nugget@gitshed:~$ git init --bare git/cherrytree.git 
 +</code>
  
 +** Step 3: Pushing to the git server **
 Now return back to the host with the ChreeyTree .ctb files and sync these files to the remote repo. Now return back to the host with the ChreeyTree .ctb files and sync these files to the remote repo.
  
-eric@kalin-emcwilliams:~/Documents/CherryTree_Docs$ git remote add origin eric@gitshed.igazine.com:/home/eric/projects/git/cherrytree.git +<code> 
-eric@kalin-emcwilliams:~/Documents/CherryTree_Docs$ git branch -M main +nugget@tiptop:~/Documents/CherryTree_Docs$ git remote add origin nugget@gitshed.igazine.com:/home/nugget/git/cherrytree.git 
-eric@kalin-emcwilliams:~/Documents/CherryTree_Docs$ git push -u origin main+nugget@tiptop:~/Documents/CherryTree_Docs$ git branch -M main 
 +nugget@tiptop:~/Documents/CherryTree_Docs$ git push -u origin main
  
 Enumerating objects: 20, done. Enumerating objects: 20, done.
Line 83: Line 106:
 Writing objects: 100% (20/20), 158.20 KiB | 17.58 MiB/s, done. Writing objects: 100% (20/20), 158.20 KiB | 17.58 MiB/s, done.
 Total 20 (delta 16), reused 0 (delta 0), pack-reused 0 Total 20 (delta 16), reused 0 (delta 0), pack-reused 0
-To gitshed.igazine.com:/home/eric/projects/git/cherrytree.git+To gitshed.igazine.com:/home/nugget/git/cherrytree.git
  * [new branch]      main -> main  * [new branch]      main -> main
 branch 'main' set up to track 'origin/main'. branch 'main' set up to track 'origin/main'.
 +
 +</code>
  
 And this is my first edit after pulling the DB down to my laptop... Holy Hell it works!  I just need to remember to git push from my laptop to the remote server and sync on my workstation before editing again.    And this is my first edit after pulling the DB down to my laptop... Holy Hell it works!  I just need to remember to git push from my laptop to the remote server and sync on my workstation before editing again.   
  
 I am saving these files as SQLite but I am now thinking I could do XML instead, the git merge possiblites are attractive but need to test. I am saving these files as SQLite but I am now thinking I could do XML instead, the git merge possiblites are attractive but need to test.
  • technical/notes_cherrytree_git_sync.1747284482.txt.gz
  • Last modified: 2025/05/15 04:48
  • by super_stunder