3

I am using git pull origin develop --rebase to rebase my commits of some other branch say X (other than develop) locally. But while rebasing (some 11 commits of X branch on top of origin/develop), while solving conflicts, I come across solving bundle.min.js file as well, which is practically impossible to solve manually. I am using git rebase --skip for skipping that commit but it will remove other file changes (other than the bundle file) as well. Any workaround to just skip changes bundle.min.js file while rebasing?

rupav jain
  • 645
  • 1
  • 7
  • 13
  • Possible duplicate of [Excluding files from Getting rebased](https://stackoverflow.com/questions/31579810/excluding-files-from-getting-rebased) – phd Jun 27 '18 at 16:19

3 Answers3

8

You can use git checkout --theirs bundle.min.js and git add bundle.min.js to "resolve" the conflict and then continue the rebase with git rebase --continue.

r3mus n0x
  • 5,954
  • 1
  • 13
  • 34
  • It wasn't clear to me whether OP wanted `--ours` or `--theirs`. – jingx Jun 27 '18 at 16:33
  • To what @jingx said: In fact, probably neither one is right. The problem is that OP is storing a derived/generated file in source control. The "correct" content of `bundle.min.js` depends on the contents of the files from which it was generated, and it's a fair bet that said content will be different in the result commit than it was in either "side" of the "merge". – Mark Adelsberger Jun 27 '18 at 19:06
  • r3mus n0x it worked ✌. Accepting this answer, as it solves the question asked. @MarkAdelsberger you are correct. I will remove it from source control. Actually we were storing it on the github because for user, one just have to clone and run (no build required - no need to have webpack/node installed by the user). – rupav jain Jun 27 '18 at 19:47
2

To the question "how do I skip a file during a rebase", r3mus n0x's answer is more or less an accurate answer. But I don't believe it addresses the issue you're facing; which is to say, it may be the wrong question.

From it's name, I would take bundle.min.js to be a build product. It's impractical to manually resolve conflicts in it for the same reason it's impractical to manually edit it. So instead you edit the source files from which it's generated, and you run a process (maybe something like gulp) with instructions to read those files and combine them and minify them.

So in that case, one solution is to resolve all of the other conflicts and then run the process that generates bundle.min.js once again, and git add the result as the correct resolution for the build product.

A better solution is to not store build products in source control.

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52
0

You can git restore --staged bundle.min.js then git restore bundle.min.js. It will restore the file to the HEAD state and not ask to choose between the HEAD and the commit being applied.

Rubixx
  • 1