Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to diff in a comment on github?

Tags:

github

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?

like image 885
catbadger Avatar asked Apr 14 '16 21:04

catbadger


People also ask

Can you do a diff on GitHub?

On the Github, go to the Source view of your project. You will see a link named 'Branch List'. Once the page opens you can see a list of all the remote branches. Hit on the Compare button in front of any of the available branches to see the difference between two branches.

How do you diff commits in git?

You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch. Order does matter when you're comparing branches.

What does ++ mean in git diff?

When viewing a combined diff, if the two files you're comparing have a line that's different from what they were merged into, you will see the ++ to represent: one line that was added does not appear in either file1 or file2.

Does GIT use diff?

Diff command is used in git to track the difference between the changes made on a file. Since Git is a version control system, tracking changes are something very vital to it. Diff command takes two inputs and reflects the differences between them. It is not necessary that these inputs are files only.

How do I compare two tags or commits on GitHub?

Here's an example of a comparison between two tags. You can also compare two arbitrary commits in your repository or its forks on GitHub in a two-dot diff comparison. To quickly compare two commits or Git Object IDs (OIDs) directly with each other in a two-dot diff comparison on GitHub, edit the URL of your repository's "Comparing changes" page.

What is git diff in Git?

So what git diff actually shows you all the changes done in the file after doing a commit for example:- a file say at.txt is modified here after doing a commit and here we can see that there is a difference in the file after a commit. Illustration: Changes between two Commits as shown below as follows:

How do I copy a git diff to GitHub?

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. Thank you. This is close but doesn't seem to color-code it the way that the examples do.

How to view differences in commits between branches in GitHub?

Here is how you can view the differences in commits: On the Github, go to the Source view of your project. You will see a link named ‘Branch List’. Once the page opens you can see a list of all the remote branches.


1 Answers

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 ``` 
like image 140
xuhdev Avatar answered Sep 21 '22 07:09

xuhdev