GIT Tutorials

GIT Tutorials

!Pasted image 20260205114324.png
Phase 1: Startup (One-time or after a fresh start)

  1. 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

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

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

  1. Close Obsidian completely.
  2. Pause Google Drive sync (Right-click the Google Drive icon in your taskbar > Settings > Pause Syncing).
  3. Open PowerShell: Press the Windows Key, type PowerShell, 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.

  1. 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
  1. 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"
  1. Move the hidden .git folder:
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."

  1. 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 .git with no .txt at the end. Windows sometimes hides extensions; if you see .git.txt, rename it to just .git.


Phase 4: Testing the Connection

  1. Check if Git sees your notes:
    In the same PowerShell window, type:
git status
  1. Re-enable Google Drive Sync. Notice that Google Drive will no longer try to sync thousands of tiny files—it will only see your .md notes and one tiny .git file.

Phase 5: The "Safe AI" Workflow

From now on, use this sequence whenever you want to use the Gemini CLI:

  1. Open PowerShell in your vault folder.
  2. Commit your current work (The "Safety Net"):
git add .
git commit -m "Safety save before AI run"
  1. Run your Gemini CLI command.
  2. Inspect the results:
    Type git diff. This shows you exactly what the AI changed.
git add .
git commit -m " save after AI run"

Reference

the Cheat Sheet Git Cheat Sheet