44

I've seen people show diffs of their code from other forks to illustrate a point in github like on this pull request thread: https://github.com/osTicket/osTicket/pull/3035

I think it would be really helpful to show the diff of the commit from the current branch. How do you do it?

2 Answers 2

80

You can pull the branch to your local copy, and make your modification. After that, copy the output of git diff and paste to GitHub as follows.

```diff
your diff file contents
```
3
  • Thank you. This is close but doesn't seem to color-code it the way that the examples do.
    – catbadger
    Apr 14, 2016 at 22:42
  • 4
    @catbadger did you type the diff specifier? I tried your diff in the comments and it works well.
    – xuhdev
    Apr 14, 2016 at 23:00
  • 2
    Is it possible to display a side-by-side diff?
    – Luciano
    Jun 2, 2021 at 9:31
38

It's worth mentioning how to write the diff:

```diff
- line removed
+ line added
```

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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