0

I am working on a Project and wanted to merge changes from a git repository.

The remote repo is not ignoring some build files, but i have added those build files to my gitignore (because with different build systems the built files would obviously differ).

So when i try to merge with:

git merge -X ours ns3-mmwave-ext/master

I get an error saying that those build files would be overwritten with merge.

I do not want them to be overwritten, so i followed this answer https://stackoverflow.com/a/26639255/4126652

and tried to do:

git add -f * // Without -f git is complaining because those build files are in my gitignore
git stash
git merge -X ours ns3-mmwave-ext/master

But that still shows the same error that the same untracked working tree files would be overwritten by merge.

Note that ns3-mmwave-ext is a remote and has already been fetched.

Edit:

I can obbiously clean the build files, but the build process is very long and i don't want to rebuild the whole thing for just a few minor changes.

Edit 2:

I am not a contributor to the remote repo so i can't just remove the build files in remote.

Community
  • 1
  • 1
Vikash Balasubramanian
  • 2,921
  • 3
  • 33
  • 74
  • My general advice would be to not add build files to your Git repo. Only source files and other related pre build things really belong there. – Tim Biegeleisen Dec 28 '16 at 09:52
  • @TimBiegeleisen I know but that's not my project and i am not a contributor and those guys are not ignoring build files. – Vikash Balasubramanian Dec 28 '16 at 09:53
  • Are these versioned remote build files actually being used to launch the program, or are they merely artifacts? – Tim Biegeleisen Dec 28 '16 at 09:56
  • @TimBiegeleisen They are used to launch the programs, but obviously the build systems may differ and i would have to rebuild them anyway in my system, so i would prefer to keep my build folder. – Vikash Balasubramanian Dec 28 '16 at 09:58
  • You can't ignore the build files, and you don't want to overwrite them, leaving few options. You should realize that the root cause is that these files should not be getting versioned. – Tim Biegeleisen Dec 28 '16 at 10:01
  • @TimBiegeleisen yeah, i realise that, i could probably do a pull request and remove those files or ask them to do it, it's a hidden build directory, so i don't think they are realising what's going on. – Vikash Balasubramanian Dec 28 '16 at 10:04
  • The problem you have is that there are a set of files, build files, which one person says should be in the repo, and the other doesn't want them there. If you must live with this, then overwriting your build files might be the only option here. – Tim Biegeleisen Dec 28 '16 at 10:06

1 Answers1

0

My suggession would be commit your build folders in other local tmp branch. Then reset your local/master with ns3-mmwave-ext/master, then pull.

# First remove 'builds' folder from .gitignore

$ git checkout tmp
$ git commit -am 'builds folder commmit'

$ git checkout master
$ git fetch
$ git reset --hard ns3-mmwave-ext/master
$ git pull origin ns3-mmwave-ext/master

$ git checkout tmp
$ git rebase master                  # now your 'builds folder commit' will be kept in top here
Sajib Khan
  • 22,878
  • 9
  • 63
  • 73