You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已在SourceTree克隆GitHub仓库,如何关联Android Studio实现修改同步?

Got it, let's walk through how to link SourceTree with Android Studio so your changes sync seamlessly. Here's a step-by-step breakdown that's worked for me and other devs:

Step 1: Ensure Android Studio uses the correct Git executable

First, we need to make sure Android Studio is using the same Git instance as SourceTree (this avoids any weird sync conflicts):

  • Open your cloned project in Android Studio
  • Go to File > Settings > Version Control > Git (Windows/Linux) or Android Studio > Settings > Version Control > Git (Mac)
  • In the Path to Git executable field, use the same Git path that SourceTree uses. You can find this in SourceTree: go to Preferences > Git (Mac) or Tools > Options > Git (Windows), copy the path, and paste it into Android Studio
  • Click Test to confirm Android Studio can connect to Git successfully

If Android Studio hasn't automatically recognized your cloned repo:

  • Go to File > Settings > Version Control
  • Click the + button, select Git, then navigate to your project's root folder (the same one you cloned with SourceTree) and click OK
  • Now Android Studio will track all file changes in your repo automatically
Step 3: Add SourceTree as an external tool in Android Studio (optional but convenient)

To open SourceTree directly from Android Studio for repo management:

  • Go to File > Settings > Tools > External Tools
  • Click the + button to create a new tool:
    • Name: SourceTree
    • Program: Paste the path to your SourceTree executable (e.g., C:\Users\<YourUsername>\AppData\Local\SourceTree\SourceTree.exe on Windows, /Applications/SourceTree.app/Contents/MacOS/SourceTree on Mac)
    • Arguments: (Optional) Add open "$ProjectFileDir$" to launch SourceTree directly on your project repo
  • Save the tool. Now you can access it via Tools > External Tools > SourceTree anytime
Step 4: Sync changes between Android Studio and SourceTree

Once everything is set up, the workflow is straightforward:

  • Make code changes in Android Studio: modified files will show up as blue, new untracked files as red
  • Commit changes locally in Android Studio via VCS > Commit (add a meaningful commit message!)
  • Open SourceTree: you'll immediately see your new local commit in the repo's history
  • Use SourceTree for remote operations: Push to GitHub, Pull updates, merge branches, or resolve conflicts
  • If you make changes in SourceTree (like pulling remote updates), go back to Android Studio and run VCS > Update Project to sync the code

Quick Tips

  • Always double-check that both tools are pointing to the exact same local repo folder—this is the most common sync issue
  • If Android Studio doesn't pick up changes, run VCS > Refresh File Status to force a status update
  • Before pushing, use Android Studio's Code > Inspect Code to catch any issues early

内容的提问来源于stack exchange,提问作者John Alex jefferson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 10:04:44