1

Is git diff related to diff?

  1. Is git diff implemented based on diff?

  2. Is the command line syntax of git diff similar to that of diff? Does learning one help using the other much?

  3. are their output files following the same format? Can they be both used by git patch and patch? (Is there git patch? How is it related to patch?)

Thanks.

4

The file format is interoperable. Git uses the best format, diff -u. It also extends it to represent additional types of changes.

The equivalent to patch is git apply. It stages the changes in the index as well as applying them to the working tree.

I remember git apply being stricter than patch, although the reference documentation doesn't seem to make an explicit comparison. It does mention several tests / errors which can be enabled or disabled.

The reference documentation also suggests that it could be used as "a replacement for GNU patch" - even outside of a git repository, if you use a certain option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.