Git rebase constantly fails and requires manual merging

I had a problem reinstalling from master to the 'deploy' branch in one of my repositories.

My repo is configured as follows:

master - of course, the main branch deploy - a branch created where files like Capfile, deploy.rb etc are created and configured - these changes will NEVER be merged back into Master 

Usually my workflow:

  • Do development on the main branch ... test, smile, commit.
  • Checkout deploy branch
  • Run git rebase master in the deployment branch - this worked without problems
  • Click on remote and then do cap deploy
  • Relax

The problem I am facing is that when I execute git rebase master in the deployment branch, an error occurs with 3-way merge / manual merge (I don't think the error message is really quite general for after). Git tells me to merge, then use git rebase --continue to complete - this never works.

What I found works: git rebase master --interactive , git rebase master --interactive the selection list (in this list, 5 or more repeated "commits" are repeated, but with different reference numbers (the same message), so I will choose one of them), and then manually perform the merge. Once I have done this for every commit, I can continue rebase and all its happy ...

Until next time, I need to rebase.

So does anyone know what can be happy? The project is not "secret", so if necessary, I can send messages, logs, branch graphs, etc.

thanks

+7
git branch rebase
source share
3 answers

It looks like this could happen, so that you have changed the history of committing these “re-commit" commits so that they have a different sha1. Each sha1 is unique not only for commit, but also for commit history. Therefore, it is impossible (which is very incredible to happen during the life of the Universe) to have two identical sha1 in one story or to have two sha1 in two different stories. If you change anything in your commit, for example, using an amendment or an interactive reinstall, you will change sha1. Thus, two commits that may look the same are actually handled differently.

So, most likely, you reinstalled from another branch, made some type of interactive redirection or made amendments to commits, continued to make some more code that modified the same part of the code, and then you have conflicts at the next permutation, because which captures what you have in your local branch that are different from the branch you are re-installing, are removed from the branch, upstream is retracted, including that you have already pulled in and changed sha1, and then when the commits are replayed onto the branch you get in confl ie, because the state code changed from what was expected commit, because it was the original, created from a different history than what you now have in your branch. Wow, that was a long sentence ...

When you “clear” the selection list ... what you do is most likely to delete these repeated commits before rebooting, so now you will not reapply the changes that have already been applied, so there will be no more conflicts.

However, if you just want to resolve conflicts during reinstallation, this is likely to be the best choice so that you don't accidentally delete the commit you want. Conflict resolution will result in a set of changes to this commitment being applicable to the story you have. After you click this merge permission permission, you won’t have to see the problem again unless you change the commits that were already pressed again.

To find which files have merge conflicts, do:

 git status 

or

 git ls-files -u 

Once you know which files have conflicts, if you have a mergetool setting, you can do:

 git mergetool <file> 

If you prefer manual merging, you can find merge tokens and strings by doing the following:

 grep -Hnr '^=\{7\}\|^<\{7\}\|^>\{7\}' * 

at the top level of your repo and editing path. When you edit manually, make sure that you remove the markers and make the final version of the file look the way you want ... git does nothing special with markers for you. When you finish editing manually, be sure to do

 git add <file> 

to add a file, to add it to the index, and to remove an unsupported flag. When you finish resolving all unrelated files, do

 git rebase --continue 

To complete rebase.

+1
source share

To get git rebase --continue to work, you must actually merge conflicting files (edit them, select the parts you want between the conflict markers "<<<<<", "=======", "→ → →> "), and then git add them to the index (the index is the place where they are written as conflicting, adding a file clears the conflicting state). Check the current diff with git diff --cached , then git rebase --continue if it looks right.

Before trying to reinstall (or after aborting the problem), check git log -p master..deploy to see the commits you are trying to reinstall. This is one of them that contradicts everything that the owner has.

Those who do what you delete by deleting their "rally lines in git rebase -i may not match (even if they have the same" subject "in their commit message). The fact that you think that there should be only one of them, indicates that something suspicious is happening in your deployment branch. Are these "recurring commits at the end of the deployment or are there other commits after them? Perhaps looking at the contents of these fish commits ( log -p , above) will give you a clue to their source.

+2
source share

You can define an attribute in the parent directory of your deployment-specific files to always select the contents of the deployment branch in case of a merge.

For an example merge manager, see this SO answer .

Other strategies have been discussed , but the key remains: always consider the merger to be "project-wide merging" rather than file-based merging. Hence, the attributes for clarifying this project merge when it comes to some “special” files.

+1
source share

All Articles