From 79e9d5e698ca5a35b3ea661422cc0b4113fda0ba Mon Sep 17 00:00:00 2001 From: Kenneth Odle Date: Sat, 25 Jan 2025 15:58:54 -0500 Subject: [PATCH] Added information on checking out earlier commits --- git-primer.tex | 15 ++++++++++++++- include/gitcheckoutcommit.tex | 3 +++ include/gitcheckoutmain.tex | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 include/gitcheckoutcommit.tex create mode 100644 include/gitcheckoutmain.tex diff --git a/git-primer.tex b/git-primer.tex index 8c263ec..96c3ddb 100644 --- a/git-primer.tex +++ b/git-primer.tex @@ -394,11 +394,24 @@ sends the output of that command to a file (\texttt{log.txt}), the first few lin 2025-01-24 0d9e1fe Kenneth Odle Added information about workflows 2025-01-22 d37d470 Kenneth Odle Added inline to-do items 2025-01-22 02d4025 Kenneth Odle Updated changelog, version number -2025-01-22 43e59f7 Kenneth Odle Significant addtions to branching chapter +2025-01-22 43e59f7 Kenneth Odle Significant additions to branching chapter \end{Verbatim} Here we get the date of the commit (in YYYY-MM-DD format), followed by an abbreviated commit hash, the name of the comitter (important if you have more than one person working on this project), and finally the commit description. +\section{Examinging Earlier Commits} + +Now that you know how to find earlier commits, you need to know how to revert to one. To do that, you simply \texttt{checkout} the earlier commit, using just enough of the SHA-1 hash to be identifiable: + +\input{include/gitcheckoutcommit} + +In this case, this would take me back to the ``Significant additions to branching chapter'' commit. + +To get back to the latest commit, we simply checkout our current branch, which in this case is ``main'': + +\input{include/gitcheckoutmain} + +Of course, the easiest way to view older commits and examine them is by using a \textit{remote} repository, because their graphical interface is far easier to navigate. \chapter{Remote Repositories} diff --git a/include/gitcheckoutcommit.tex b/include/gitcheckoutcommit.tex new file mode 100644 index 0000000..38661ae --- /dev/null +++ b/include/gitcheckoutcommit.tex @@ -0,0 +1,3 @@ +\begin{Verbatim}[] +$ git checkout 43e59f7 +\end{Verbatim} diff --git a/include/gitcheckoutmain.tex b/include/gitcheckoutmain.tex new file mode 100644 index 0000000..46ee782 --- /dev/null +++ b/include/gitcheckoutmain.tex @@ -0,0 +1,3 @@ +\begin{Verbatim}[] +$ git checkout main +\end{Verbatim}