简体   繁体   中英

GIT: Ignore file when pulling but not when pushing

I have a GIT repo to do frontend mostly: Scss preprocessor and JS.

The problem is that we change different .scss files and compile them into a .css one (we are 4, 5 and sometimes 6 frontends) and it gives a conflict when pulling. .css files always throw a conflict.

This is reasonable, since .css file is always different, but I want to ignore those conflicts, since we have a LOT of merges to solve those conflicts (Unnecessary merges, from our point of view) .

I cannot ignore the .css file in GIT, because project managers and others are always pulling the repo to test and show to clients.

Is there a way that we can always PUSH our .CSS file but not PULL it?

The canonical answer is that you're doing it wrong and you're not supposed to store generated files, such as these .css in your case. Typical workflow and environment to work with generated (compiled) files usually involves:

  • Storing only sources in version control
  • Developers each compile their own target files (usually slightly different due to environment differences) using their own development boxes / environments
  • There is some sort of "deployment" process that compiles and produces "deployable artifacts" (ie in stable environment with reproducible results, given the same set of source files)
  • These artifacts have the following life cycle:artifacts:
    • first, they get deployed to the stage environment,
    • then QA checks it throughly,
    • finally they get deployed into production.

However, your mileage may vary, of course. Could you elaborate, what was your original reason to commit generated files into the repository?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM