将 .jar 文件添加到 git 存储库中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40068608/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add .jar files into a git repository
提问by Yini
I have a project on eclipse where recently i created a new folder called lib and added some .jar files inside. I cannot seem to commit the changes to git. It just doesnt appear in the tracked list of files.. I have removed .jar from .gitignore in my branch and commited the changes, and still the same.
我在 Eclipse 上有一个项目,最近我创建了一个名为 lib 的新文件夹,并在其中添加了一些 .jar 文件。我似乎无法将更改提交给 git。它只是没有出现在跟踪的文件列表中。我已经从我的分支中的 .gitignore 中删除了 .jar 并提交了更改,但仍然相同。
采纳答案by Maksym Chernikov
You put your files in the project package, but you didn't put them under version control. All you need is to add them to VCS by "git add" command. Here is good documentation.
您将文件放在项目包中,但没有将它们置于版本控制之下。您只需要通过“git add”命令将它们添加到 VCS。这里有很好的文档。
You should use this command in git bash or in terminal (if you have added git to path)
您应该在 git bash 或终端中使用此命令(如果您已将 git 添加到路径)
Also I recommend you to use build manager as Maven, Gradle or Ant to add you dependencies. Good luck!
此外,我建议您使用构建管理器作为 Maven、Gradle 或 Ant 来添加依赖项。祝你好运!
回答by R11G
The way I got it working for me was -
我让它对我来说有效的方式是 -
git add --force /path/to/the/NAME_Of_THE_JAR.jar
回答by Mohit Garg
in the .gitignore file present in your project, you need to make sure that you allow *.jar files to be pushed. In my case, *.jar files was listed in ignore list. So I removed it from that list and git was able to detect it and I was able to push it.
在项目中存在的 .gitignore 文件中,您需要确保允许推送 *.jar 文件。就我而言,*.jar 文件列在忽略列表中。所以我从那个列表中删除了它,git 能够检测到它并且我能够推送它。
回答by Lucas Oliveira
You can identify if your .jar is needed to be added using the command git diff
, git will indicate if you need to add the files to your repository.
Them use git add .
and your files will be available for commit.
您可以使用命令确定是否需要添加 .jar git diff
,git 将指示您是否需要将文件添加到存储库中。他们使用git add .
,您的文件将可供提交。