GIT Tutorials
GIT Tutorials
!Pasted image 20260205114324.png
Phase 1: Startup (One-time or after a fresh start)
cd "C:\Users\Srika\Srikanth Kamath GDrive\My Drive\obsidian notes\my New Notes"
git init
git add .
git commit -m "initial Commit"
# optional Set your identity (first time only)
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Phase 2: Pre-AI Snapshot
git status # (Confirm current state)
git add .
git commit -m "pre-ai: [describe current task]"
Phase 3: The AI Run
- Use Gemini CLI to modify the vault.
gemini
exit with /quit
Phase 4: The Audit
git diff --stat` (See a summary of which files changed)
git diff [filename].md (Inspect specific files for property/tag errors)
Phase 5: Outcome
- IF ERROR:
git restore .(Instantly resets to your "pre-ai" commit) - IF SUCCESS: *
git add .
git commit -m "post-ai: [describe what the AI did]"
!Pasted image 20260205114919.png
GIT Branches
| Goal | Old Way (checkout) | New Way (switch) |
|---|---|---|
| Switch to an existing branch | git checkout main |
git switch main |
| Create and switch to new branch | git checkout -b feature-1 |
git switch -c feature-1 |
| Go back to previous branch | git checkout - |
git switch - |
| Discard local changes in a file | git checkout -- file.txt |
git restore file.txt* |
Using GIT When the Folder is mounted on Cloud
To stop the corruption, we are going to perform "surgery" on your vault. We will move the Git database (the part that crashes when Google Drive touches it) to your local C: drive, while keeping your notes on Google Drive.
Follow these steps exactly, one by one.
Phase 1: Preparation
- Close Obsidian completely.
- Pause Google Drive sync (Right-click the Google Drive icon in your taskbar > Settings > Pause Syncing).
- Open PowerShell: Press the
Windows Key, typePowerShell, and press Enter.
Phase 2: Moving the Git "Brain"
We are moving the .git folder out of the vault so Google Drive can't see it.
- Create the safe house for your Git data:
Copy and paste this into PowerShell:
New-Item -Path "C:\git-metatdata\AI_TSK_Notes" -ItemType Directory -Force
- Go to your Google Drive Vault:
(I am using the path you provided earlier):
cd "C:\Users\Srika\Srikanth Kamath GDrive\My Drive\obsidian notes\my New Notes"
- Move the hidden
.gitfolder:
Move-Item -Path ".git" -Destination "C:\git-metatdata\AI_TSK_Notes\" -Force
If you get an error saying it doesn't exist, you might have already deleted it or it's hidden. If so, move to the next step.
Phase 3: Creating the "Pointer" File
Now we tell Git: "My notes are here on GDrive, but my history is on the C: drive."
- Create the pointer file (Ensure you are still in the GDrive folder):
Set-Content -Path ".git" -Value "gitdir: C:/git-metatdata/AI_TSK_Notes/.git"
Crucial: The file must be named exactly
.gitwith no.txtat the end. Windows sometimes hides extensions; if you see.git.txt, rename it to just.git.
Phase 4: Testing the Connection
- Check if Git sees your notes:
In the same PowerShell window, type:
git status
- Success: You will see a list of your markdown files.
- Fail: You will see "fatal: not a git repository." (If this happens, check the path inside the
.gitfile).
- Re-enable Google Drive Sync. Notice that Google Drive will no longer try to sync thousands of tiny files—it will only see your
.mdnotes and one tiny.gitfile.
Phase 5: The "Safe AI" Workflow
From now on, use this sequence whenever you want to use the Gemini CLI:
- Open PowerShell in your vault folder.
- Commit your current work (The "Safety Net"):
git add .
git commit -m "Safety save before AI run"
- Run your Gemini CLI command.
- Inspect the results:
Typegit diff. This shows you exactly what the AI changed.
- If you see corrupted tags or broken formatting, type:
git restore .
This instantly undoes everything the AI did. - If all good
git add .
git commit -m " save after AI run"
Reference
the Cheat Sheet Git Cheat Sheet