What git gotchas have you been caught by?

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

这不是一个陷阱,而是一个混帐


Publishing to public repository without realizing my git config user.name was incorrect.
That means the public repo now gets a name (and an email) I would rather not have published at all. If that repo is replicated, ... it is too late.

That is why I prefer having my user.name displayed in my git prompt shell, meaning instead of having this:

 MY_HOSTNAME /c/Prog/myGitProject (master)$

I see this:

 MY_HOSTNAME /c/Prog/myGitProject (master) VonC $

I know who I am from the very first command I type in this Git bash session!

链接地址: http://www.djcxy.com/p/45308.html

上一篇: 将多个PDF文件合并/转换为一个PDF文件

下一篇: 你被抓到了什么git陷阱?