0

I have two different remote branches that I push to. One is to acquia (git push acquia dev) and one is github (git push origin dev).

Before I can push to acquia however I have to run a git pull. When i run "git pull acquia dev" I get

The following untracked working tree files would be overwritten by merge: docroot/sites/default/files/box1.jpg docroot/sites/default/files/box3.jpg docroot/sites/default/settings.php

Now, I don't want to overwrite these files (they are in my gitignore), I just want them to be ignored. How do i merge the branches so that they can be ignored?

Philip
  • 569
  • 2
  • 5
  • 27
  • It may be in your gitignore, but the fact that you are getting that error means that the file is checked in to one or more repositories. Is that file supposed to be checked in, if not, get it out of the repository with `git rm`. If it is supposed to be checked in, why is it in your gitignore? – mkasberg Apr 25 '16 at 19:16
  • It's supposed to be in the repostiory, but my local files and the repository files are supposed to differ – Philip Apr 25 '16 at 19:30
  • 1
    But if it's supposed to be in the repo, it means it's supposed to be on your computer once you check out the repo or merge from it. So you can't have them ignored. Therefore, since in your version of the repo the files are ignored and in the repo's version they aren't, git (correctly) informs you that the merge would overwrite your local versions since in the repo they are not ignored. If you want to have them different, then un-ignore them and commit their new content locally. – CherryDT Apr 26 '16 at 15:51
  • Hm I think I understand now that in your local fork they should be ignored (for reasons other than just being different from the remote version). Is that true? In this case you would to actively "delete" them using `git rm --cached` (shouldn't delete them from disk, but backup anyway) and merge that in. You would still get a conflict every time the files are changed remote, but you can just resolve it by telling Git you want to use your ("deleted") version. – CherryDT Apr 26 '16 at 15:58
  • There are changes to that file that conflict with your local file. You need to resolve the conflicts one way or another (even if it's just keeping your local changes). There are lots of ways to do this. I would: remove from gitignore, `git stash save "my changes"`, `git pull`, `git stash pop`, resolve any conflicts, push any required changes to origin, and if you want put it back in the gitignore. – mkasberg Apr 26 '16 at 19:33
  • This seems like the best answer however i resolved this by cloning the acquia repo, and then forcing the push to the github repo.... would have loved to have tried this. Will remember for future! – Philip May 02 '16 at 18:10

0 Answers0