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

如何修改Git Bash的起始文件夹?修改‘Start in’属性无效求助

Fixing Git Bash's Default Startup Folder (When "Start in" Doesn't Work)

Hey there! I’ve run into this exact issue before—tweaking the Start in field in properties often doesn’t stick for Git Bash because it prioritizes its own shell configuration. Let me walk you through two reliable fixes that actually work:

Method 1: Modify the Git Bash Shortcut Target (Quick Per-Shortcut Fix)

This is great if you want a specific shortcut to open in your desired folder:

  • Right-click your Git Bash shortcut and select Properties
  • In the Target field, you’ll see something like:
    "C:\Program Files\Git\git-bash.exe"
    
  • Append the --cd flag with your target path (wrap the path in quotes if it has spaces):
    "C:\Program Files\Git\git-bash.exe" --cd="D:\Projects\MyRepo"
    
  • Click Apply then OK, then launch Git Bash again—it should open directly in your chosen folder.

Method 2: Edit Bash Configuration Files (Permanent Global Fix)

This makes Git Bash open in your target folder no matter which shortcut you use:

  1. Open Git Bash and run this command to find your home directory:
    echo $HOME
    
    You’ll get a path like C:/Users/YourUsername (Git uses forward slashes here).
  2. Navigate to that folder in File Explorer. If you don’t see hidden files, enable them (View > Show > Hidden items).
  3. Look for files named .bash_profile or .bashrc. If neither exists, create a new text file named .bash_profile (make sure it doesn’t have a .txt suffix—Windows might hide it by default, so double-check).
  4. Open the file in a text editor and add this line (replace the path with your target folder, using forward slashes and the Git-style drive prefix like /d/ instead of D:\):
    cd /d/Projects/MyRepo
    
  5. Save the file, close Git Bash, and reopen it. It’ll now automatically navigate to your target folder on startup.

Quick Troubleshooting Tip

If you’re using a newer version of Git for Windows, your shortcut might already have a --cd parameter—just replace the existing path in that flag instead of adding a new one.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 12:21:27