Tuesday, March 8, 2011

Gotcha git

So hopefully mentioning them here will help me remember not to do a couple of things.

First DO NOT, EVER, push to a non-bare repository, unless you will immediately 'git reset HEAD'. When you push to a non-bare repository, git for some reason inserts the pushed files "before" the existing working directory. This means that current working directory, without your pushed changes, is seen as having changes after your commit. So if you commit the working directory you pushed to, you effectively revert everything you just pushed!!!

Second, be very, very careful with submodules. Every commit to a submodule has to be committed both the the submodule AND to the parent module! If you to do both, everyone dies. Well, maybe not, but you all other clones of the parent directory will be broken until you go pack and do both commits.

Even worse are the terrible terrible consequences of 'git add submodule/' with the trailing slash included. Rather than add the changes in the submodule to the list of changes to commit, this will remove the submodule from the repository and re-add all of the individual files contained in the submodule. I'm not quite sure why this was determined to be the desired behavior, but whatever.

Anyhow, I thought I'd also throw up a couple of handy references for generic git stuff.

No comments:

Post a Comment