你被抓到了什么git陷阱? [英] What git gotchas have you been caught by?

查看:118
本文介绍了你被抓到了什么git陷阱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到过的最糟糕的是使用git submodules。我有一个github项目的子模块。该项目没有维护,我想提交补丁,但不能,所以我分叉。现在子模块指向原始库,我需要它指向叉子。因此,我删除了旧的子模块,并在同一提交中将其替换为新项目的子模块。原来,这打破了其他人的存储库。我仍然不确定处理这种情况的正确方法是什么,但是我最终删除了子模块,让所有人都拉动和更新,然后创建新的子模块,并让每个人都再次拉动和更新。它花了一天的更多时间来弄清楚。



其他人以非明显的方式意外搞砸了git存储库,以及您是如何解决的它是什么?

添加一个子模块


当你在子模块上使用git add时,确保你没有



 > git add local / path 
- 添加子模块

> git add local / path /
- 将子模块中的所有文件直接添加到您的存储库中,big no-no


The worst one I've been caught by was with git submodules. I had a submodule for a project on github. The project was unmaintained, and I wanted to submit patches, but couldn't, so I forked. Now the submodule was pointing at the original library, and I needed it to point at the fork instead. So I deleted the old submodule and replaced it with a submodule for the new project in the same commit. Turns out that this broke everyone else's repositories. I'm still not sure what the correct way of handling this situation is, but I ended up deleting the submodule, having everyone pull and update, and then I created the new submodule, and had everyone pull and update again. It took the better portion of a day to figure that out.

What have other people done to accidentally screw up git repositories in non-obvious ways, and how did you resolve it?

解决方案

The usual trailing slash when adding a submodule:

When you use git add on a submodule, make sure you don’t have a tailing slash.

> git add local/path
  -- adds the submodule

> git add local/path/
  -- adds all the files in the submodule directly into your repository, big no-no

这篇关于你被抓到了什么git陷阱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆