“git format-patch” equivalent for a single file?

2020-05-30 01:53发布

问题:

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!

回答1:

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...



标签: git