2

I'm using git for a Laravel project that uses Webpack to minify javascript files and SCSS to generate CSS files.

I have a master branch and a ws branch.

When I'm in the ws branch and want to run git rebase master, I'm currently seeing 54 steps of conflicts.

Almost all of them are ones relating to the public/js or public/css directories or composer.lock or public/mix-manifest.json.

During my rebase, I don't want to spend any time manually resolving each of those conflicts because I plan to run npm run production afterwards anyway (which will regenerate public/mix-manifest.json and all the files in public/js) and take care of the SCSS and composer too.

I've read about git rerere but get the sense that it is not helpful here.

I also don't want to manually run git checkout --ours dozens of times.

How can I make my rebase process faster and easier?

P.S. I wonder if Choose Git merge strategy for specific files ("ours", "mine", "theirs") is related.

Ryan
  • 22,332
  • 31
  • 176
  • 357
  • 2
    So these files are the output of your build? Can you just .gitignore them? – Oliver Charlesworth Apr 26 '18 at 20:02
  • @OliverCharlesworth I'm using deployhq.com to deploy straight from my git repo, which is why I haven't used .gitignore on those folders. – Ryan Apr 26 '18 at 20:04
  • 1
    That sounds like the crux of your problem. I don't know anything about DeployHQ, but is it really the case that it can't orchestrate build steps as part of a deploy? – Oliver Charlesworth Apr 26 '18 at 20:07
  • @OliverCharlesworth I think that will be an option (although I think they'll charge for it monthly), so I'll consider it if I can't figure out something else. I'd rather not mess with my deployment process unless absolutely necessary. Thanks. – Ryan Apr 26 '18 at 20:13
  • Oliver's suggestion is sound. Fix the root problem rather than deal with the accidental complexity it generates. – jub0bs Apr 26 '18 at 21:29
  • @Jubobs I agree with the principle that addressing a root cause is better than surface-level solutions. What I'm not clear on yet is why you're saying git shouldn't contain files generated by a build. What is the principle or best practice that I should be following? – Ryan Apr 26 '18 at 22:46
  • 1
    @Ryan As a rule of thumb, no file that can be generated from source should be under version control. You should use a tool other than Git to handle (build, deploy, etc.) artifacts. Like Oliver, I'm not familiar with DeployHQ, but a cursory search reveals that it can build stuff as part of the deployment: https://www.deployhq.com/support/build-commands Look into that. – jub0bs Apr 26 '18 at 23:14
  • I agree that you should rather not have them in git at all. But as a side note, `git checkout` can glob like any other cli tool. So you can do `git checkout --ours public/*` – lukas-reineke Apr 27 '18 at 09:07

0 Answers0