0

I have two branches master and docs. The second one has files that I never want in the master branch, however when I perform an update in master I would like to update the docs branch without altering its extra files.

I tried to use merge, however, it fails due to the extra files in the docs branch.

Can you help me with this?

Thank you.

Isidrogv
  • 26
  • 2
  • It's most likely possible using some combination of flags on some git command, but I'd say – it's a sign you're not using git "right" (not to your advantage). It sounds like `docs` should be a folder, not a branch. – rsmeral Jun 07 '21 at 21:41
  • What do you mean by the merge "fails"? Unless there is something you have not included in your questions it should be possible to merge `master` into `docs` despite `docs` having files that `master` does not. – TheIceBear Jun 07 '21 at 22:01
  • The error when I try to merge is: `Merging is not possible because you have unmerged files. hint: Fix them up in the work tree, and then use 'git add/rm '` and only when I delete the extra files (or add them in `master`), it works. – Isidrogv Jun 07 '21 at 23:38
  • 2
    That particular error message (`you have unmerged files`) implies that you already started a merge earlier, and have not yet finished it. You cannot start a *new* merge until you finish, or terminate, the earlier one. – torek Jun 09 '21 at 02:13
  • did you try to rebase docs? – sab Jun 11 '21 at 13:34

1 Answers1

0

Overwriting specific files or directories from the master branch in the docs branch works for me. For example, assuming that directory_to_update is older in the docs branch, I did the following to update (overwrite) it with respect to master:

$ git checkout docs
$ git checkout master directory_to_update

Then the following message appears: Updated N paths from ..., and the files have been "updated".

Similar to the answer in https://stackoverflow.com/a/18115667/7749658

Isidrogv
  • 26
  • 2