【问题标题】:Git says nothing to commit after running ng build --prodGit 在运行 ng build --prod 后没有说什么要提交
【发布时间】:2021-05-04 13:26:52
【问题描述】:

我在 VSCode 终端中保存了对文件的更改。运行以下命令:

git status(This showed the changes.)
git add .
git status (This showed the files added)
git commit -m "My commit message."
git push (This showed the files were pushed up to git).

然后我运行ng build --prod。构建运行没有问题。我运行git status 并得到以下信息:

$git 状态 在分支 qa 你的分支是最新的'origin/qa'。

没什么可提交的,工作树干净

我在正确的分支上。我已经重建了很多次,没有问题。任何人都知道如何解决它。

【问题讨论】:

  • (* 表示 提交 被推送到 git)
  • 这里有什么问题?如果您推送,为什么分支不会与原始分支保持同步?你还期待什么?
  • 看到答案后你一定知道将编译/构建的输出代码保留在git中并不是一个好习惯。

标签: angular git visual-studio-code


【解决方案1】:

Angular 构建通常保存在根路径下的 dist 文件夹中。

在 .gitignore 文件中,声明了在源代码管理中省略的路径。 dist 文件夹就是其中之一。这就是您在git status 期间看不到文件的原因。

这是 .gitignore 文件内容的示例。

# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist -----> /dist is mentioned in this file
/tmp
/out-tsc

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

【讨论】:

  • @mwave317 请注意,dist 文件夹通常不会提交,因为它们可以定期且频繁地更改。另外,它应该能够从其余文件中生成
【解决方案2】:

你的/dist目录在项目根目录下的.gitignore文件中,如果需要将编译后的版本上传到git(可以这样做,但不是一个好习惯),应该去掉这个目录从 .gitignore 文件中,再次运行git status 进行检查

【讨论】:

  • 我可以通过 ng build --prod --watch 解决问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-24
  • 2018-06-30
  • 2017-12-30
  • 1970-01-01
  • 2019-12-29
  • 2021-08-16
相关资源
最近更新 更多