You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

使用GitHub Desktop提交本地新仓库时提示“Commit failed - exit code 1 received”

Fixing "Commit failed - exit code 1 received" in GitHub Desktop

Hey there, let's work through this frustrating error together. This is one of the most common hiccups with GitHub Desktop, and it almost always ties back to a small, easy-to-fix issue. Here are the steps to diagnose and resolve it:

1. Check your commit message

GitHub won't let you make an empty commit, and some special characters (like rare emojis or system-unrecognizable symbols) can break the process.

  • Open the commit box in GitHub Desktop, make sure you've entered a clear, non-empty message (e.g., Initial commit: Add core project files).
  • Remove any odd characters or symbols from the message, then try committing again.

2. Verify local repository folder permissions

If your system user doesn't have read/write access to the repository folder, GitHub Desktop can't save the commit.

  • On Windows: Right-click your repo folder → PropertiesSecurity tab → Ensure your user account has "Read & Write" permissions.
  • On Mac: Right-click the repo folder → Get Info → Scroll to "Sharing & Permissions" → Make sure your user has "Read & Write" access.
  • Restart GitHub Desktop after adjusting permissions, then retry the commit.

3. Fix Git configuration mismatches or corrupted repo state

Sometimes your local Git config is out of sync with your GitHub account, or the repo's internal state is corrupted. Grab a terminal (Git Bash for Windows, Terminal for Mac) and run these commands from your repo directory:

  • First, navigate to your repo: cd /path/to/your/local/repository
  • Set your Git username to match GitHub: git config --global user.name "YourGitHubUsername"
  • Set your Git email to match GitHub: git config --global user.email "your-github-email@example.com"
  • If that doesn't work, reset the repo's tracked files:
    • git rm -r --cached . (clears the Git cache)
    • git add . (re-adds all files to tracking)
  • Now go back to GitHub Desktop and try committing again.

4. Check for oversized files

GitHub blocks individual files larger than 100MB (unless you use Git LFS). If you have a big file in your repo, it'll cause this error silently.

  • Run this terminal command in your repo to find the largest files: git ls-files --size | sort -n -r | head -5
  • If you spot a file over 100MB:
    • Either move it outside the repo and delete it from Git tracking, or
    • Set up Git LFS to manage the large file, then retry the commit.

5. Clear GitHub Desktop's cache

Occasionally, the app's cached data gets corrupted. Here's how to fix it:

  • Close GitHub Desktop completely.
  • Navigate to the cache folder:
    • Windows: C:\Users\<YourUsername>\AppData\Roaming\GitHub Desktop
    • Mac: ~/Library/Application Support/GitHub Desktop
  • Delete the Cache and Cookies folders (leave config.json and other important config files untouched).
  • Restart GitHub Desktop and attempt the commit again.

内容的提问来源于stack exchange,提问作者Rahul Raj

火山引擎 最新活动