Visual Studio Code:错误:Git执行失败

7
我在Windows 10机器上安装了VS Code(版本:1.12.1),之后安装了Git(版本:2.13.0.windows.1)。 然后:
  1. 我创建了一个Asp.Net项目(图1)

  2. 我在VS Code中打开它,进入源代码控制,点击初始化存储库(图2)

  3. 我尝试提交更改(图3)。

  4. 然后我看到了这个错误消息(图4)。
  5. 然后我确保git是提供者(图5)
  6. 我去了settings.json并覆盖了git路径(图6),默认情况下它设置为null。但这并没有解决问题。我从头开始创建另一个应用程序,仍然显示相同的错误消息。
请点击此处查看截图
以下是Git Log输出:
Using git 2.13.0.windows.1 from C:\Program Files\Git\cmd\git.exe
git rev-parse --show-toplevel
git rev-parse --show-toplevel
fatal: Not a git repository (or any of the parent directories): .git

fatal: Not a git repository (or any of the parent directories): .git

fatal: Not a git repository (or any of the parent directories): .git

git rev-parse --show-toplevel
fatal: Not a git repository (or any of the parent directories): .git

git init
git rev-parse --show-toplevel
git status -z -u
git symbolic-ref --short HEAD
git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

git for-each-ref --format %(refname) %(objectname)
git remote --verbose
git show :../../AppData/Roaming/Code/User/settings.json
git status -z -u
git symbolic-ref --short HEAD
git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

git for-each-ref --format %(refname) %(objectname)
git remote --verbose
git show :../../AppData/Roaming/Code/User/settings.json
git add -A -- .
git commit --quiet --allow-empty-message --file - --all

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'COMPAQ@PREPARA12.(none)')

git config --get-all user.name
git show :../../AppData/Roaming/Code/User/settings.json
git status -z -u
git symbolic-ref --short HEAD
git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

git for-each-ref --format %(refname) %(objectname)
git remote --verbose
git show :../../AppData/Roaming/Code/User/settings.json
git commit --quiet --allow-empty-message --file -

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'COMPAQ@PREPARA12.(none)')

git config --get-all user.name
git show :../../AppData/Roaming/Code/User/settings.json
git status -z -u
git symbolic-ref --short HEAD
git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

git for-each-ref --format %(refname) %(objectname)
git remote --verbose
git show :../../AppData/Roaming/Code/User/settings.json
git fetch
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.

git fetch
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.

git fetch
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.

git fetch
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.

git fetch
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.

git commit --quiet --allow-empty-message --file -

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'COMPAQ@PREPARA12.(none)')

git config --get-all user.name
git status -z -u
git symbolic-ref --short HEAD
git rev-parse master
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

git for-each-ref --format %(refname) %(objectname)
git remote --verbose

1
请按照日志中建议的方式,使用“git config”配置您的电子邮件和姓名。 - J.N.
非常感谢!呵呵。我是Git的新手,一直害怕日志输出,但是当我读了你说的话后,我明白这很简单。下次我会毫无畏惧地阅读日志!谢谢! - Lucas
你好。现在它是否按预期工作? - J.N.
是的!我将user.email和user.name设置为全局变量,现在即使我创建一个新项目,也不会再收到那个错误消息了。 - Lucas
不错啊,你先是拒绝了我对你的问题添加适当的代码格式的编辑,然后又进行了类似的编辑。 - Picard
显示剩余2条评论
1个回答

1

从上面的评论中:

阅读Git的日志输出。配置您的用户电子邮件和用户名。一种方法是打开命令提示符。然后使用cd FILEPATH导航到您的文件夹。然后配置您的用户电子邮件和用户名。可以全局配置或仅在当前存储库中配置。通过以下方式进行全局配置:

git config --global user.email "youremailaddress@example.com"

那么

git config --global user.name "Your Name"

相关的Github问题:https://github.com/Microsoft/vscode/issues/57222#issuecomment-417216329 - lechat

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接