GitBash启动VSCode终端锁定求助:code .命令执行后终端无法操作
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
codecommand in PATH
Open VS Code, pressCtrl+Shift+Pto bring up the command palette, then search for and runShell 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 typingcode . &(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:- Open Git Bash and run
cd ~to navigate to your user directory. - Edit your
.bashrcor.bash_profilefile (whichever exists) usingcode .bashrc. - Add this line at the bottom:
alias code='code "$@" &' - 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.
- Open Git Bash and run
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

