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?
Asked
Active
Viewed 2,247 times
2 Answers
5
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.
Stephen Kitt
- 411,918
- 54
- 1,065
- 1,164
-
1Will use that in the future. It didn't work now as I didn't initialize the database as I thought it would do that on its own - especially as I noticed how several .git folders were created automatically via some other tool. I didn't know it needed to be configured first because there was nothing on its website nor a popup / wizard after installation. But I guess people are used to reading the man pages for tools. – mYnDstrEAm Aug 06 '17 at 22:34
-
It’s generally useful to read at least the [`README`](https://etckeeper.branchable.com/README/) (which in this case is quite good). – Stephen Kitt Aug 07 '17 at 07:14
-
`gitk` looks like a great tool to use w/`etckeeper`. I wondered if there was a CLI-only version available as my Raspberry Pi is the "zero graphics"/Lite distro. There are some promising ideas covered in this [thread on SO](https://stackoverflow.com/questions/5361019/viewing-full-version-tree-in-git); this one in [particular :)](https://stackoverflow.com/a/18287861/5395338) – Seamus Jan 25 '22 at 12:36
-
1@Seamus in terminals I use `tig`. – Stephen Kitt Jan 25 '22 at 12:38
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
cas
- 1
- 7
- 119
- 185