While I’m currently struggling with these problems in a project that uses git, this is not really asking solutions to specific problems, but I’m more asking for what are the possible causes for these types of problems. (The problems have been fixed, but their reason is a mystery.)
What can cause erratic behavior with git, especially when rebasing? Erratic behavior that’s very hard to solve, tends to mess up the entire commit history, and often the easiest (although laborious) solution is to do a hard reset and then cherry-pick individual commits in order to fix and clean up the commit history. The kind of erratic behavior I’m referring to includes things like:
- Duplicated commits appearing in the commit log, with different hashes. In other words, the exact same commit, with the exact same modifications and time/date, is randomly duplicated one or several times, with no rhyme or reason, each duplicate having its own different hash. Some commits may have been duplicated just once, others even four times, and there’s no logic to their order or placement in the commit log (they may appear one after another, or separated by a half dozen other commits, out-of-order in relation to the commit date of other commits, etc.)
- Inside a branch (that has been created from the master branch), when trying to do a “git rebase master”, it causes a merge conflict with a file that exists only in this branch and nowhere else. In other words, the file in question does not exist in the master branch (and has never existed there), and it was created and has only ever existed in this branch. Essentially, git is trying to merge the file with an older version of the same file in the same branch (which makes absolutely no sense).
- There’s the master branch and branches A and B made from it. There exist two files in the project, “x/name” and “y/name”. In branch A the former is renamed “z/name” (ie. the directory is renamed), and then this change is merged into the master branch. Then in branch B I do a “git rebase master” to get those changes, and git gives a rename conflict, as it tries to rename “x/name” as “y/name”, which once again makes absolutely no sense. (I don’t have the faintest idea what caused this, or how such a conflict is supposed to be resolved. Especially since it’s an incorrect attempt at renaming the file.)
I am becoming a master (hah!) at doing hard resets and cherry-picking commits to the current branch to try to fix its commit history and resolve rebasing conflicts. I just wish I didn’t have to constantly do that. I would really love to get some ideas of what could cause this completely erratic and asinine behavior.