Syncing with git
Enter the right folder
pwd //显示当前文件夹路径(print working directory)
ls //**列出当前文件夹里的内容**(list directory contents
../ //回到上一层目录My path
cd "/Users/jz/Library/Mobile Documents/iCloud~md~obsidian/Documents/plugin-use-CN"Sync to GitHub
- Create a new repo on GitHub — don’t check README / .gitignore (we create those locally) — and get the repo’s SSH URL.
- Enter your local project directory Initialize the repo
git initCreate .gitignore
touch .gitignore
Common things to ignore for an Obsidian plugin
node_modules/
dist/
.obsidian/
.DS_Store- First commit Check the current status
git statusStage all files
git add .Commit
git commit -m "init: first commit"- Push the local code to GitHub Bind the remote repo
git remote add origin ssh-urlDouble-check (optional)
git remote -vPush to GitHub
Rename the local branch (GitHub’s default branch is main; rename your local branch to main so the sync works — you can check the name with git branch)
git branch -M mainPush the branch to GitHub and set up tracking
git push -u origin main- Day-to-day push flow Stage
git add .Commit message
git commit -m Sync
git pushForce-overwrite the remote repo
git push -f- Commit message conventions
feat: 新功能
fix: 修 bug
refactor: 重构
docs: 文档
style: 只改格式Rolling back a git version
View the commit history
git log --onelineRoll back HEAD while keeping your working-tree changes
git reset --soft <commit_hash>Undo the rollback Find the commit you had before the rollback
git reflogPoint HEAD back to the original commit
git reset --soft original-hashDon’t roll back — just dig out the old code
Check out an entire old version into some temporary place
git show d31e499:src/ui/SidebarOverviewView.ts -- “/Users/jz/Library/Mobile Documents/iCloud~md~obsidian/Documents/all-in/.obsidian/plugins/learning-system/src”Submodules
Say the plugin lives in repo A, and repo B needs to reuse A’s plugin. Set this up in repo B:
git submodule update --remotegit commit -am "update a-plugin"git clone --recurse-submodules +A仓库的shhSubsequent sync flow
git submodule update --remotegit commit -am "update learning-system submodule"If a plugin with the same name already exists locally but isn’t a submodule
rm -rf .obsidian/plugins/learning-systemgit submodule add [email protected]:jady21a/obsidian-learning-system.git .obsidian/plugins/learning-systemgit commit -m "add learning-system submodule under .obsidian/plugins"
Verify it worked
git submodule status