29

A collegue of mine forked my project and we want to incorporate his changed on a single file into my repo, keeping its history (mainly the commit logs).

The problem is that he clumsy in his commits so the commits contains diff from other files as well, unrelated to the project (or what need to be pulled into the original repo).

I would like to be able to do a "git format-patch" to extract the history, but only for a single file (or maybe two, the .cpp and .hpp files). I could not find an option to "format-patch" for this.

Is it possible?

Thanx!

big_gie
  • 2,829
  • 3
  • 31
  • 45

1 Answers1

38

Hum... So actually it's as simple as:

git format-patch commit_id file(s)

where commit_id is the parent of the first commit to create a patch followed by the file or files wanted...

big_gie
  • 2,829
  • 3
  • 31
  • 45
  • 4
    Simply add a '--' if some of the files you want to follow do not exist locally in master : `git format-patch --output-directory myPatch commit-id-begin..commit-id-end -- file1 file2 file3` – Autiwa Feb 05 '13 at 09:48
  • 1
    That wasn't working for me until I saw this - http://stackoverflow.com/a/7885229/1603711 - I needed to use `git format-patch -1 commit_id -- file(s)` – Russell England Nov 13 '15 at 16:46