针对Gemfile.lock是否应该包含在.gitignore中?和gitlock文件这两个问题,本篇文章进行了详细的解答,同时本文还将给你拓展.gitignore和.gitkeep有什么区别?-Wh
针对Gemfile.lock 是否应该包含在 .gitignore 中?和git lock文件这两个问题,本篇文章进行了详细的解答,同时本文还将给你拓展.gitignore 和.gitkeep 有什么区别? - What are the differences between .gitignore and .gitkeep?、.gitignore 文件是否要提交到 git 中、.gitignore被Git忽略 - .gitignore is ignored by Git、.npmignore、.gitignore和package.json中的files字段等相关知识,希望可以帮助到你。
本文目录一览:- Gemfile.lock 是否应该包含在 .gitignore 中?(git lock文件)
- .gitignore 和.gitkeep 有什么区别? - What are the differences between .gitignore and .gitkeep?
- .gitignore 文件是否要提交到 git 中
- .gitignore被Git忽略 - .gitignore is ignored by Git
- .npmignore、.gitignore和package.json中的files字段
Gemfile.lock 是否应该包含在 .gitignore 中?(git lock文件)
我对捆绑器及其生成的文件有点陌生。我有一份来自 GitHub 的 git repo 的副本,该副本由许多人贡献,所以我惊讶地发现 bundler
创建了一个在 repo 中不存在且不在.gitignore
列表中的文件。
由于我已经分叉了它,我知道将它添加到 repo 不会破坏主 repo 的任何内容,但是如果我执行 pull request,它会导致问题吗?
应该Gemfile.lock
包含在存储库中吗?
答案1
小编典典2021 年的简单答案: Gemfile.lock 也应该在 Rubygems 的版本控制中 。接受的答案现在是 11 岁。
这里有一些推理(从评论中挑选):
@josevalim
https://github.com/heartcombo/devise/pull/3147#issuecomment-52193788
Gemfile.lock 应该保留在存储库中,因为贡献者和开发人员应该能够分叉项目并使用保证工作的版本运行它。
@rafaelfranca
https://github.com/rails/rails/pull/18951#issuecomment-74888396
我认为即使对于插件也忽略锁定文件不是一个好主意。
这意味着“git clone;bundle;rake
test”序列不能保证通过,因为您的数十个依赖项中的一个已升级并导致您的代码中断。此外,正如@chancancode 所说,它使平分变得更加困难。
Rails 在 git 中也有 Gemfile.lock:
- https://github.com/rails/rails/commit/0ad6d27643057f2eccfe8351409a75a6d1bbb9d0
.gitignore 和.gitkeep 有什么区别? - What are the differences between .gitignore and .gitkeep?
问题:
What are the differences between .gitignore
and .gitkeep
? .gitignore
和.gitkeep
什么.gitkeep
? Are they the same thing with a different name, or do they both serve a different function? 它们是不同名称的同一个东西,还是它们都起着不同的作用? I don''t seem to be able to find much documentation on .gitkeep
. 我似乎无法在.gitkeep
上找到太多文档。
解决方案:
参考一: https://stackoom.com/question/UKp3/gitignore 和 - gitkeep 有什么区别参考二: https://oldbug.net/q/UKp3/What-are-the-differences-between-gitignore-and-gitkeep
.gitignore 文件是否要提交到 git 中
.gitignore 文件是否要提交到 git 中。
起因
项目报错,因为少了 jar 包。
原因就是有人把 .gitignore 提交了,里面把 *.jar 都忽略,所以本地增加了 jar 却忘记提交 git。
优点
过虑本地不需要的文件,提交时容易看得清楚。
缺点
如果大家用不同IDE或编辑器,会生成不同的文件需要 ignore,即不同人的 .gitgnore 可能会不一样,提交了会影响别人。
一句话就是,改了会影响别人。
另外一种解决方法,本地全局 ignore。
git 可以设置一个全局的忽略文件,这样就不会影响其他人,只对你所有本地 git 项目都忽略指定文件。
在 windows 用户目录(类似于 linux ~/.gitconfig)下有一个:
C:\Users\Administrator\.gitconfig
里面会指定一个全局 ignore 文件位置:
[core]
excludesfile = C:\\Users\\Administrator\\Documents\\gitignore_global.txt
(另外还有个 hgignore_global.txt,貌似(不确定)是 sourceTree 的忽略文件)
gitignore_global.txt 文件即全局忽略配置,加到里面则不会影响其他人的项目。也不用 commit 这个文件上去。
这种方法也有个缺点:
如果经常切换机器时可能就得自己搬这个文件了。
参考:
https://stackoverflow.com/questions/5765645/should-you-commit-gitignore-into-the-git-repos
.gitignore被Git忽略 - .gitignore is ignored by Git
问题:
My .gitignore
file seems to be being ignored by Git - could the .gitignore
file be corrupt? 我的.gitignore
文件似乎已被Git忽略.gitignore
文件是否已损坏? Which file format, locale or culture does Git expect? Git需要哪种文件格式,语言环境或文化?
My .gitignore
: 我的.gitignore
:
# This is a comment
debug.log
nbproject/
Output from git status
: 从git status
输出:
# On branch master
# Your branch is ahead of ''origin/master'' by 1 commit.
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# debug.log
# nbproject/
nothing added to commit but untracked files present (use "git add" to track)
I would like debug.log
and nbproject/
not to appear in the untracked files list. 我希望debug.log
和nbproject/
不会出现在未跟踪的文件列表中。
Where should I start looking to fix this? 我应该从哪里着手解决此问题?
解决方案:
参考一: https://stackoom.com/question/m34B/gitignore被Git忽略参考二: https://oldbug.net/q/m34B/gitignore-is-ignored-by-Git
.npmignore、.gitignore和package.json中的files字段
本文参考了这篇文章https://docs.npmjs.com/misc/developers;
问题场景:npm publish发布一个npm包,发布的时候你希望只发布打包的文件,包的源码,单元测试等文件不希望发布;
.npmignore中的文件不会被发布,默认情况下,npm publish发布目录中的所有文件,除了
.*.swp
._*
.DS_Store
.git
.hg
.npmrc
.lock-wscript
.svn
.wafpickle-*
config.gypi
CVS
npm-debug.log
所以不需要把这些文件加入到.npmignore中也会忽略,如果没有.npmignore,有.gitignore,那么.gitignore中的文件会从包中忽略,如果同时存在,那么.npmignore的优先级更好,体会一下:
If you want to include something that is excluded by your .gitignore file, you can create an empty .npmignore file to override it. Like git
并且.gitignore和.npmignore中的文件是递归查找的,再体会一下:
npm looks for .npmignore and .gitignore files in all subdirectories of your package, not only the root directory.
这些是默认发布的文件,加入.gitignore和.npmignore都是不会生效的:
package.json
README
(and its variants)CHANGELOG
(and its variants)LICENSE
/LICENCE
所以当你npm publish的时候,为啥总会有package.json文件,明白了吧?这几个文件在npm publish的时候都是默认作为包的一部分的
介绍下package.json中的files字段,这个字段中的文件默认会加入到npm publish发布的包中,它的优先级高于.npmignore和.gitignore,这个才是使用最广的方法,好像很多开源项目用的都是files字段
关于Gemfile.lock 是否应该包含在 .gitignore 中?和git lock文件的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于.gitignore 和.gitkeep 有什么区别? - What are the differences between .gitignore and .gitkeep?、.gitignore 文件是否要提交到 git 中、.gitignore被Git忽略 - .gitignore is ignored by Git、.npmignore、.gitignore和package.json中的files字段的相关知识,请在本站寻找。
本文标签: