- a lot of times, when you do your works on branch, and as days passed, you wanna review your own codes by browsing through the history but no idea how?
- or maybe you want to let you colleague take a look at the work you have done and code review for you?
- or see the changes you made in the branch and write a change log before you merge back into the master branch.
Today, we are going to learn just that.
With command line, you can use git log. LEAD-451 is an example of my branch and it is here for illustration purposes but you should change to the branch you want to view.
git log master...LEAD-451
this will show the changes including commit, author, date, message. If you notice, the order is chronological, with latest being to top and oldest at the bottom. You can use --reverse to see the oldest first.
If you want to see the file status, if you add --name-status to the command
.If you want to see the actual code changes, it is very intuitive, you use git diff. So
git diff master...LEAD-451
and you get a lengthy code different output between branch master and branch LEAD-451. If you want to generate a patch, you can give -p to the command. If you want to see what files change/add/delete between these two branches, you can add parameter --name-status or --name-only.
Enough for the command line, now we go for some visual representation. For this, I will illustrate using github.
With the same condition, in github, there is a feature called compare view.
As you can see on the bottom, the output is very much same with the command line we have tried before this. But github condense everything into one , very nice.
Assuming you are at your project landing page at github, how do you quickly get the compare view?
- at the front page, https://github.com/Opentracker/luceneOnCassandra/
- click on the branch drop down, select the branch you want to diff. example LEAD-451
- at the page https://github.com/Opentracker/luceneOnCassandra/tree/LEAD-451, you can click on the compare button.
That's it, I hope you learned something and please donate as a mean to continue funding this blog maintenance. Thank you.