2

I had a branch devel from which I branched out A topic branch in the past.

devel was always intended to be the parent of A (everything devel had/hadn't should reflect in A). After a long time, I've added some files to .gitignore and updated the index of devel to reflect it.

Now I'm trying to merge devel back into A again.. to reflect those changes (.gitignoreed files from it) but it gives me a merge conflict in those ignored files. I don't want those ignored files in A. How do I tell that to git?

screenshot if it helps... enter image description here

Community
  • 1
  • 1
laggingreflex
  • 32,948
  • 35
  • 141
  • 196

1 Answers1

1

I would rather, before merging devel to A, making sure all devel ignored files are ignored as well in A.

The trick for that is to remove from the index of A everything, update the .gitignore content, and add everything back!

git checkout A
# update the .gitignore file from devel in A
git checkout devel -- .gitignore

# remove/add everything
git rm --cached -r .
git add .
git commit -m "new commit with devel gitignore files out" 

# then
git merge devel
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks! But can I remove/add everything but with a GLOBAL gitignore? (so that it remove/add everything from ALL branches?) Because otherwise it's basically just doing the same thing I did with the `devel` (remove/add everything acc. to new `.gitignore`). Merging after that would be kinda pointless...(except for preserving semantic-relationships) And I'll have to do this with every `A`,`B`,`C`… – laggingreflex Jun 17 '13 at 10:43
  • 1
    @laggingreflex I would presume merging that would not be pointless: you would merge devel to all the branches, which can have non-ignored files with evolutions of their own, hence the merge. And you should be able to script my proposed sequence of commands easily enough for each branches (s i http://stackoverflow.com/a/3847586/6309). – VonC Jun 17 '13 at 11:08