What is a git diff, how to do it, and what is it for?

Asked

Viewed 1,303 times

1

I’m having a problem with my project.

I make contributions to a git project, and when I check the Master branch, I saw that some methods are missing that you have in a branch, but don’t have in Master. I can not say how many and what are these methods, so I believe it would be good to make a DIFF among branchs, however, I do not know if it is the right one to do to solve this problem and also do not know the correct sintax for this. Another point is, a DIFF command will resolve this divergence between branchs? At some point in development and commits, these methods were lost, by some conflicts that arose, are many people updating the same classes. Can someone help me solve this problem?

1 answer

2


The syntax for the diff between branches is:

$ git diff origin/[branch1]..origin/[branch2]

The diff won’t resolve the divergence, it’ll just show the difference between them. To solve it you can merge the branches or rebase and solve conflicts in the files.

If you need to check the change history of a file, you can run the command:

$ git log -p caminho/do/arquivo

You can still use the Cherry pick git to restore files in specific commits.

  • Thanks a lot, I’m sure you’ve helped a lot. Taking advantage of the kindness, I’d like one more piece of information. A DIFF lists the difference between the branchs? Because my idea is to take the difference between the branchs, change anything in these classes, commit them and open a merge request, to move those updates up in the Master branch. Since, in merge request, only what has been changed/updated since the last open merge is merged, that is, things that have not changed. are not merged or committed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.