How can I view diffs or at least older versions of specific files with etckeeper?

So I’m using etckeeper on my machine running Debian 9.1 with KDE and would like to view diffs (or if that isn’t yet implemented: past versions) of specific files. How can I do that?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

By default, with etckeeper, /etc is a git repository, so you can use git tools to view its contents (and the changes). For example, you can use gitk (after installing it) to browse the repository’s history, and if you want to focus on a specific file, you can specify it on the command line:

cd /etc
gitk apt/sources.list &

Since you’re a KDE user, you might find qgit nicer.

Method 2

I just use git log and git show or git diff. e.g.

# git log --oneline /etc/squid/squid.conf
907df30 saving uncommitted changes in /etc prior to apt run
a612769 daily autocommit
6d45b99 saving uncommitted changes in /etc prior to apt run
0f21707 daily autocommit
9a95a9b saving uncommitted changes in /etc prior to apt run
b2518f4 daily autocommit
338b4a7 daily autocommit
862d5e6 committing changes in /etc after apt run
ff6a8fd daily autocommit
2d64d79 saving uncommitted changes in /etc prior to apt run
7e3bb0e Initial commit


# git diff a612769 907df30 /etc/squid/squid.conf
diff --git a/squid/squid.conf b/squid/squid.conf
index 0e08217..e630ed9 100644
--- a/squid/squid.conf
+++ b/squid/squid.conf
@@ -7876,9 +7876,3 @@ forwarded_for off
 #  not all I/O types supports large values (eg on Windows).
 #Default:
 # Use operating system limits set by ulimit.
-
-#httpd_accel_host virtual
-#httpd_accel_port 80
-#httpd_accel_with_proxy on
-#httpd_accel_uses_host_header on
-

If I wanted the full contents of a specific revision of a file, I’d use git ls-tree (to get the sha1 of the file blob) and git cat-file to output it. e.g.

# git cat-file blob "$(git ls-tree a612769 /etc/squid/squid.conf | 
                       awk '{print $3}')" > /tmp/squid.conf.a612769


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x