Git:处理 .class 文件和其他编译对象

发布于 2024-10-05 20:30:20 字数 318 浏览 0 评论 0原文

假设我有几个具有不同代码的分支:BranchA 和 BranchB。假设我当前在 BranchA 上并运行构建。假设我的构建将 .class 文件和其他编译对象转储到工作树中的目录中。当我运行 diff 时,我看到目录已更改,因为其中包含新的编译对象。

如果我切换到 BranchB 并部署我的代码,那么我实际上是在部署从 BranchA 的代码库编译的对象,因为 git 跨分支切换维护了我的浮动更改(新编译的对象)。这显然是一个错误。

有几种方法可以避免这种情况,一种是每当我们切换分支时清理非版本化文件,但是有没有一种更简单的方法来处理这个问题。我真的不想将编译的对象放入版本控制中。

Lets say I have a couple branches with different code: BranchA and BranchB. Assume I'm currently on BranchA and run a build. Suppose that my build dumps .class files and other compiled objects into directories within the work tree. When I run a diff, I see that directories have changed because they have new compiled objects within.

If I switch to BranchB and deploy my code, then I'm actually deploying objects compiled from BranchA's code base, since git maintained my floating changes (new compiled objects) across the branch switch. This is obviously a mistake.

There are a few ways to avoid this, one being cleaning up non-versioned files whenever we switch branches, but is there a more fool-proof way of taking care of this issue. I'd really rather not put compiled object into version control.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罪歌 2024-10-12 20:30:20

我所做的

  1. 使用 .gitignore 从存储库中排除已编译的文件,
  2. 使部署过程成为干净和编译的一部分。

What I do

  1. use .gitignore to exclude compiled files from the repo
  2. make a clean and compile part of your deployment process.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文