Home » Software Development » Git » Git ChangeLog Example

About Jun Wu

Jun Wu
Jun (Steven) Wu is a current Master student in Computer Science & Engineering department of University of Nebraska Lincoln (Lincoln, NE, USA). His current interests focus on Programming Languages (Java, Python), Relational Database (MySQL), NoSQL Database (Apache Cassandra, MongoDB), and Computer Networks.

Git ChangeLog Example

1. Introduction

Git has been popularly used among software developers. It shows great power by its distributed nature, fast operation and branch handling mechanism. In addition, it’s very convenient for developers to work together. And this is really important for cooperating coding.

Meanwhile, Github is an online web-based repository hosting service platform. It’s also quite utilized for developers to share their codes. At the same time, it provides a great platform for engineers from different regions to work on the same project.
 
 
 

 
In this article, I’ll introduce the usage of how to track the logs for your project. In the following example, all are shown in MacOS EI Capitan Version 10.11.5 and the Git version is 2.7.4.

2. Git logs

2.1 git log

As we know, we can use Git command to manage our projects. And this includes some basic commands, like git add, git commit, git push etc. Among these commands, git commit is quite often used. And it holds the current state of the repository. Every commit has a pointer to the parent commit object. So, you can go back to the parent commit object by changing the pointer.

For keeping tracking of your code changes, you should often commit your code and push to the remote repository. Every commit you make is a hint for your changes. Hence, it could be very useful for you to keep record of your project.

Based on commits you’ve made, it moves forward. So to manage your code, it’s important to have logs for the changes. Then, we can use the command git log to make it. Basically, git log is used for showing the commit logs.

2.2 git log example

To make it clear, we make a simple example. For instance, we create a folder called GitLogExample. Meanwhile, we create a txt file named README. Then we add content of “Hi there!” in the txt file. Finally we initialize it as a git project.

WXMs-MacBook-Pro:~ WXM$ cd Documents/JCG/
WXMs-MacBook-Pro:JCG WXM$ ls
GitDiffExample	GitLearning	Git_repository
WXMs-MacBook-Pro:JCG WXM$ mkdir GitLogExample
WXMs-MacBook-Pro:JCG WXM$ cd GitLogExample/
WXMs-MacBook-Pro:GitLogExample WXM$ cat README.txt
Hi there!
WXMs-MacBook-Pro:GitLogExample WXM$ git init
Initialized empty Git repository in /Users/WXM/Documents/JCG/GitLogExample/.git/

Then, we make simple changes to the txt file, adding the name. It shows like below:

WXMs-MacBook-Pro:GitLogExample WXM$ cat README.txt
Hi there!

I'm Steve.

Step by step, we make small changes to the file. At the same time, we commit it. Finally the file comes to be like below:

WXMs-MacBook-Pro:GitLogExample WXM$ cat README.txt
Hi there!

I'm Steve.

Nice to meet you here.

It's easy to use Git.

I'm in a test branch.

I'm in a master branch now.

As we introduced in the above section, it’s convenient to keep track of the logs with the usage of git log. It shows like below:

WXMs-MacBook-Pro:GitLogExample WXM$ git log
commit c0dcbb248590501db40ba286e52ec4ca6aa2d372
Author: Jun 
Date:   Fri Aug 5 22:08:06 2016 -0500

    master branch

commit a439d39a9f5e7ac4274b55a0923f0e6d3716c971
Author: Jun 
Date:   Fri Aug 5 22:03:13 2016 -0500

    a new branch test

commit 94de23feeda610e1b8e15e66e2d5712ccb547189
Author: Jun 
Date:   Fri Aug 5 22:00:22 2016 -0500

    Easy to learn git

commit 0534eff571470c409ad16102807796619899f63a
Author: Jun 
Date:   Fri Aug 5 21:56:15 2016 -0500

    nice to meet you

Meanwhile, we can have a simple version of the logs with the command of git log --oneline --decorate

WXMs-MacBook-Pro:GitLogExample WXM$ git log --oneline --decorate
c0dcbb2 (HEAD -> master, origin/master) master branch
a439d39 (origin/branch_test, branch_test) a new branch test
94de23f Easy to learn git
0534eff nice to meet you
2307d89 add name
f615f6d first readme file

3. Git changelog

For Github projects, it might be more useful to have changelogs. Basically, a change log is a log file. It contains a curated chronologically ordered list of notable changes for each version of a project. Hence, it makes life easier for users and contributors to see precisely what notable changes have been made between each release (or version) of the project.

Normally, there’s no default changelog for each project. However, it could be better if we have one. To make a changelog for our project, you may want to refer to a Github project called Github-Changelog-Generator. The link for this project is https://github.com/skywinder/Github-Changelog-Generator.

However, to installed it, you need to have ruby on your machine. Then run the command with sudo gem install github_changelog_generator. After the successfully installation of Github-Changelog-Generator, you may go to the folder of your project. Here, for simplify, we use one of my previous example GitTreeViewerExample.

After this, just type the command github_changelog_generator in your terminal.

WXMs-MacBook-Pro:~ WXM$ cd Documents/JCG/GitTreeViewExample/
WXMs-MacBook-Pro:GitTreeViewExample WXM$ github_changelog_generator
Performing task with options:
{:tag1=>nil,
 :tag2=>nil,
 :date_format=>"%Y-%m-%d",
 :output=>"CHANGELOG.md",
 :base=>"HISTORY.md",
 :issues=>true,
 :add_issues_wo_labels=>true,
 :add_pr_wo_labels=>true,
 :pulls=>true,
 :filter_issues_by_milestone=>true,
 :author=>true,
 :unreleased=>true,
 :unreleased_label=>"Unreleased",
 :compare_link=>true,
 :enhancement_labels=>["enhancement", "Enhancement"],
 :bug_labels=>["bug", "Bug"],
 :exclude_labels=>
  ["duplicate",
   "question",
   "invalid",
   "wontfix",
   "Duplicate",
   "Question",
   "Invalid",
   "Wontfix"],
 :max_issues=>nil,
 :simple_list=>false,
 :verbose=>true,
 :header=>"# Change Log",
 :merge_prefix=>"**Merged pull requests:**",
 :issue_prefix=>"**Closed issues:**",
 :bug_prefix=>"**Fixed bugs:**",
 :enhancement_prefix=>"**Implemented enhancements:**",
 :git_remote=>"origin",
 :user=>"wuxiaomin98",
 :project=>"GitTreeViewExample",
 :token=>nil}
Found 2 tags
Fetching tags dates: 2/2
Sorting tags...
Received issues: 0
Fetching merged dates: 0
Filtered pull requests: 0
Filtered issues: 0
Fetching events for issues and PR: 0
Fetching closed dates for issues: Done!
Generating log...
Done!
Generated log placed in /Users/WXM/Documents/JCG/GitTreeViewExample/CHANGELOG.md

Then, you can see that a CHANGELOG.md file is generated in the same folder. Similarly, add the changelog file and commit it. Then push it to your Github account. It shows like below:

Change Log

2.0 (2016-08-22)

Full Changelog

1.0 (2016-08-06)

* This Change Log was automatically generated by github_changelog_generator

You may checkout the real version of this in the link of https://github.com/wuxiaomin98/GitTreeViewExample/blob/master/CHANGELOG.md.

Everything is done!

4. Conclusion

In conclusion, it’s a good way to have a changelog file in your project. This could keep track of your project release version and make your life easier. Though there’s no default changelog for the Github project. Luckily we have many useful tools to help us mange this. Github-Changelog-Generator is one of those. Meanwhile, it’s also very useful to check the logs for our project.

(No Ratings Yet)
Start the discussion Views Tweet it!

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

 

and many more ....

 

Receive Java & Developer job alerts in your Area

 

Leave a Reply

avatar
  Subscribe  
Notify of