I have installed husky in my project. Then I ran the precommit
command. Now, when I run the git
command, it is not working and it's instead asking me how do you want to open the file. So, I removed husky using npm prune
and then removed the hooks folder from /.git
of the project directory, but still didn't help. I am using Windows 10.
First, in the built-in terminal, type: git --version
.
If that command does not work, download and install the latest version of Git. Else, in VS Code's extensions, in the search bar type: @builtin
. This will list all the built-in extensions in VS Code categorized under different sections. In the 'Features' section look for Git extension. Check if it is disabled. Enable it and your version control should start working.
I had a somewhat similar issue - VS Code stopped working with Git (for example: no change detection, problems with fetching from remotes), but I couldn't find what caused this issue (I didn't install Husky like what the OP did).
Inspired by @user9795515's answer, I resolved the problem with Git by restarting the Git feature in VSC:
- Go to Extensions
- In the search bar type @builtin
- Find Git and Git Base features and disable them
- Restart VS Code
- Re-enable both features
After reading the other posts with their answers of deleting and reinstalling Git and Github, I discovered that I had the Atom GitHub package installed from prior experiments. I deleted Atom and restarted VSCode and it now works with the Git repo.
Try to check from Terminal, if Git command is recognized.
Curently I'm using Powershell terminal.
git --version
this should be return like this git version 2.28.0.windows.1
If that doesn't work then try these steps:
- Check VS Code Terminal Setting as explained on this link VS Code Documentation
- Update setting.json. My settings would be like this.
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"args": ["-NoExit", "-ExecutionPolicy", "Unrestricted", "-NoProfile", "-File", "C:\\Users\\LENOVO\\Documents\\WindowsPowerShell\\bootstrap-git.profile.ps1"],
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
}
}
- Close Terminal, and then Run Terminal again, and check if Git command is recognized with
git --version
. - Additional setting for Powershell to includes Git Command in
bootstrap-git.profile.ps1
file which is used in Point 2.
# Start a transcript
#
if (!(Test-Path "$Env:USERPROFILE\Documents\WindowsPowerShell\Transcripts"))
{
if (!(Test-Path "$Env:USERPROFILE\Documents\WindowsPowerShell"))
{
$rc = New-Item -Path "$Env:USERPROFILE\Documents\WindowsPowerShell" -ItemType directory
}
$rc = New-Item -Path "$Env:USERPROFILE\Documents\WindowsPowerShell\Transcripts" -ItemType directory
}
$curdate = $(get-date -Format "yyyyMMddhhmmss")
Start-Transcript -Path "$Env:USERPROFILE\Documents\WindowsPowerShell\Transcripts\PowerShell_transcript.$curdate.txt"
# Alias Git
#
New-Alias -Name git -Value "$Env:ProgramFiles\Git\bin\git.exe"
Alternatively, if you're already installed Git, then try to using Git Bash Terminal in VS Code.
I was facing the same problem, however my git --version
was working on cmd.
I have set up C:\Program Files\Git\bin
and C:\Program Files\Git\cmd
in PATH
(Windows -> envirorment variable -> PATH). Once I did that I restarted cmd and Visual Studio Code and it fixed the issue.
Had this same problem. Below is the solution that worked.
- Open Vscode
- Ctrl + Shift + P
- Type 'select default profile'
- Choose any terminal aside Powershell.
Don't know why powershell isn't working but changing to either CMD and Git bash works just fine.
I have same problem and below step help me to fix my problem:
unistall vs code and git then install them again.
check the version of git
go to settings Git:Enable and check it
in your Terminal write:
git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY git commit -allow-empty -n -m "Initial commit"
Try running git config --global safe.directory *
in your terminal.
© 2022 - 2024 — McMap. All rights reserved.