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

GitBash启动VSCode终端锁定求助:code .命令执行后终端无法操作

Fix Git Bash Locking After Running code . to Launch VS Code

Hey there! I’ve run into this exact issue before, and it’s almost always tied to how VS Code integrates with Git Bash on that specific machine. Let’s walk through the fixes step by step:

  • Reinstall the VS Code code command in PATH
    Open VS Code, press Ctrl+Shift+P to bring up the command palette, then search for and run Shell Command: Install 'code' command in PATH. This ensures the command is properly registered in your system’s environment variables, which can fix misconfigurations that cause the terminal to hang.

  • Force VS Code to run in the background
    If typing code . & (adding the ampersand to send the process to the background) lets you get back to the command line right away, you can make this permanent with an alias:

    1. Open Git Bash and run cd ~ to navigate to your user directory.
    2. Edit your .bashrc or .bash_profile file (whichever exists) using code .bashrc.
    3. Add this line at the bottom: alias code='code "$@" &'
    4. Save the file, then restart Git Bash. Now running code . will automatically launch VS Code in the background and return you to the command prompt.
  • Update Git Bash and VS Code
    Outdated software can cause compatibility glitches. Check if your Git Bash version is older than your working machines—head to the official Git site to grab the latest installer. Do the same for VS Code (go to Help → Check for Updates) to ensure you’re running the most recent build.

  • Adjust Git Bash’s shell mode
    Right-click the Git Bash title bar, select Options, go to the Terminal tab, and toggle the "Run as login shell" setting. Some environment variable differences between login and non-login shells can affect how VS Code launches from the terminal. Restart Git Bash after changing this to test if it fixes the lockup.

These steps should get your Git Bash behaving just like your other two devices. Let me know if any of these don’t work—I can help troubleshoot further!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 08:28:31