# Git auto-sync/commit

**URL:** https://community.silverbullet.md/t/git-auto-sync-commit/1568
**Category:** v1: Troubleshooting (legacy)
**Created:** [January 2, 2025, 4:11am UTC](https://community.silverbullet.md/t/git-auto-sync-commit/1568 "2025-01-02T04:11:40Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![vuau](https://community.silverbullet.md/user_avatar/community.silverbullet.md/vuau/32/554_2.png) [@vuau](https://community.silverbullet.md/u/vuau)
#### Post date: [January 2, 2025, 4:14am UTC](https://community.silverbullet.md/t/git-auto-sync-commit/1568/2 "2025-01-02T04:14:59Z")

</div>

Hope it helps

```auto
silverbullet.registerEventListener({name: "editor:pageSaved"}, async (event) => {
  // Clear the existing timeout if the function is called again before the delay
  if (debounceTimeout) {
    clearTimeout(debounceTimeout);
  }

  // Set a new timeout
  debounceTimeout = setTimeout(async () => {
    try {
      // Invoke the git sync command
      await system.invokeFunction("git.syncCommand");
      console.log("Git sync command executed successfully.");
    } catch (error) {
      console.error("Failed to execute Git sync command:", error);
    }
  }, 60000 * 5); // 5 minute delay
});

```

---

_[View the full topic](https://community.silverbullet.md/t/git-auto-sync-commit/1568)._
