To change the default directory where Git Bash opens in Windows 10, you must modify the shortcut properties rather than relying on command-line arguments. This approach ensures that every time you launch the terminal from your desktop or taskbar, it automatically navigates to your preferred workspace folder.
Git Bash is a powerful tool for developers who need a Unix-like environment on Windows, but its default behavior often starts in the user profile directory. Many users find this inconvenient when they primarily work within specific project folders. By adjusting the shortcut configuration, you can streamline your workflow and reduce the number of manual commands required to reach your working directory. This method is reliable across different versions of Git for Windows and does not require complex scripting or registry edits.
Understanding the Shortcut Properties
The most effective way to set a custom starting directory is through the Windows shortcut system. When you install Git for Windows, it creates shortcuts on your desktop and potentially pins them to your taskbar. These shortcuts are essentially executable links that point to the
git-bash.exe file. The target path includes several parameters that control how the application behaves upon launch.
You do not need to use flags like
--cd=, which are not standard for this purpose. Instead, you will edit the "Start in" field within the shortcut's properties. This field explicitly tells Windows which directory to set as the current working directory before executing the shell script. It is a native Windows feature, ensuring compatibility and stability regardless of the Git version you are using.
Modifying the Desktop Shortcut
If you typically launch Git Bash from your desktop, follow these steps to update the starting location:
- Locate the Shortcut: Find the Git Bash icon on your desktop. If it is not there, open the Start menu, search for "Git Bash", right-click the result, and select "More" then "Open file location". This will take you to the shortcut file.
- Access Properties: Right-click the Git Bash shortcut and select "Properties" from the context menu. Alternatively, you can click on the shortcut once to highlight it and press
Alt+Enter.
- Edit the Target Field: In the Properties window, ensure you are on the "Shortcut" tab. Look for the "Target" box. This contains the path to
git-bash.exe. You generally do not need to change this unless you are moving the installation.
- Set the Start-in Folder: Locate the "Start in:" box just below the Target field. Clear any existing content and paste or type the full path to your desired directory (e.g.,
C:\Users\YourName\Projects). Ensure you use forward slashes if needed, though backslashes usually work fine here.
- Apply Changes: Click "Apply" and then "OK" to save the changes. Double-click the shortcut to verify that Git Bash now opens directly in the specified folder.
This process is straightforward and immediate. Any subsequent launches via this specific shortcut will respect the new setting. If you have multiple projects, you might consider creating separate shortcuts with different "Start in" paths for each major workspace.
Updating Taskbar Pinned Shortcuts
Many users prefer to keep Git Bash pinned to their taskbar for quick access. However, pinning a shortcut creates a copy of the link, meaning changes made to the original desktop shortcut may not reflect on the taskbar version. To fix this, you must update the pinned item directly.
Right-click the Git Bash icon on your taskbar. If you see "Pin to taskbar" grayed out, it means it is already pinned. Instead, look for an option to manage the shortcut or simply right-click the name that appears in the jump list. A more reliable method is to unpin the current icon, apply the changes to the original shortcut file as described above, and then re-pin the updated version.
When you drag the newly configured shortcut onto the taskbar, Windows will recognize it as the same application and replace the old entry. Verify the new start-up directory by launching it from the taskbar. This ensures consistency between your desktop and taskbar experiences.
Alternative Methods and Considerations
While modifying shortcuts is the most common solution, some users might explore other options. You can configure Git Bash to remember the last used directory by adding settings to your
.bashrc file, but this requires additional scripting and may not persist correctly if the session crashes. Another approach involves using environment variables, but this affects all applications, not just Git Bash.
For those who frequently switch between many directories, keeping multiple shortcuts with different "Start in" paths is often more efficient than trying to force a single global default. This allows you to tailor each launch to the specific project context.
If you encounter issues where the directory resets unexpectedly, check if any group policy scripts or third-party software are overriding the shortcut properties. Additionally, ensure that the path you entered exists and that your user account has read/write permissions for that folder.
For related troubleshooting on Windows systems, you might find our guide on
How to Fix Hard Drive Issues on Windows 7 and Windows 10 helpful if you suspect file system errors are affecting your shortcuts.
Frequently Asked Questions
Does changing the shortcut affect the actual installation path?
No, modifying the "Start in" field only changes the initial working directory for the session. It does not move or alter the location of the
git-bash.exe binary itself. Your Git installation remains intact in its original folder.
Can I use relative paths in the Start-in field?
It is highly recommended to use absolute paths. Relative paths can be ambiguous depending on where Windows resolves the execution context, leading to unpredictable results or errors when the shortcut is launched from different locations.
Why does Git Bash still open in my home directory after I changed the shortcut?
This usually happens if you edited the wrong shortcut or if the taskbar icon is a separate instance. Always verify that you are editing the exact shortcut file you intend to use. Unpinning and repinning the taskbar icon often resolves this discrepancy.
Is there a way to make this change permanent for all users?
You would need to modify the shortcut files located in the public user profiles or use Group Policy Preferences to deploy the shortcut with the correct "Start in" setting to all machines in a domain environment.
What happens if the specified directory is deleted?
Git Bash will likely fail to launch or will open in a fallback directory such as the user's home folder. It is good practice to ensure that the directory specified in the "Start in" field always exists and is accessible.