1

With git, I want to replace all the files, except some specific ones, in branch A with the same files from branch B.

I don't want to merge because I don't want branch A to have the history of these specific files from B.

I have lost several hours and made many tests and didn't find the answer. Can you help me?

Medical physicist
  • 2,510
  • 4
  • 34
  • 51

2 Answers2

0

you can use the usual merge, since you don't the history from A to go into B you can use squashing-commits-with-rebase so it will be 1 commit inthe hisotry

Mzf
  • 5,210
  • 2
  • 24
  • 37
  • I'm using answer http://stackoverflow.com/a/7292109/2235673 to select the files. How should I commit to avoid including in the history the files that I don't want to be included? – Medical physicist Feb 21 '16 at 22:07
0

Note that you either have to have all of the history of B or none of the history of B; I assume you want the latter.

First, while on branch A, do git checkout B . (make sure to include the period at the end). This will overwrite all the files in your working directory with those from B. Then, for each file you don't want from B, do git checkout A /path/to/filename. This will "un overwrite" those files. Then commit, and you're done.

David Deutsch
  • 17,443
  • 4
  • 47
  • 54