Began branching example

This commit is contained in:
Kenneth John Odle 2024-08-21 14:43:34 -04:00
parent 354ae98ca8
commit 72aaa279f6

View File

@ -202,7 +202,7 @@ If you're happy with the files you've staged, we can now commit them by using \t
\chapter{Branches}
If you want to experiment, the best way to do that is to create a \textit{branch}. To do that, just use \texttt{git branch <name>}. To move to that branch, you check it out\footnote{For a visual depiction, see, \kref{https://www.youtube.com/watch?v=8qxDBiiVjlQ}{https://www.youtube.com/watch?v=8qxDBiiVjlQ}.} using \texttt{git branch checkout <branchname>}.
If you want to experiment, the best way to do that is to create a \textit{branch}. To do that, just use \texttt{git branch <name>}. To move to that branch, you check it out using \texttt{git branch checkout <branchname>}.
Of course, there's a shortcut to this. You can use
@ -210,13 +210,23 @@ Of course, there's a shortcut to this. You can use
\noindent{}which creates a branch called ``branchname'' and moves you to it automatically.
This is the point where you can experiment and have fun on this branch without worrying about messing up your main branch. Wouldn't it be nice if life were like this?\footnote{Gosh, I've mentioned this twice. There are lots of science fiction stories about this possibility. I guess it's time to go read one. Or write one.} If you like the changes that you made on this branch, you can then go back to your main branch (\texttt{git checkout main}) and \textit{merge} those changes.
This is the point where you can experiment and have fun on this branch without worrying about messing up your main branch. If you like the changes that you made on this branch, you can then go back to your main branch (\texttt{git checkout main}) and \textit{merge} those changes.
\input{include/merge}
It's always a good idea to clean up after ourselves. If we don't need that experimental branch any more, we can delete it with \texttt{git branch -d <branchname>}.
In reality, things are rarely going to be this simple, unless you are only making very basic changes to a branch. You'll likely get all sorts of error messages or warning messages, and will get confused or even scared. Never fear! The nice thing about Git is that most of the solutions you need are easily found at the other end of a web search.
In reality, things are rarely going to be this simple, unless you are only making very basic changes to a branch. You'll possibly get all sorts of error messages or warning messages, and will get confused or even scared. The nice thing about Git is that most of the solutions you need are easily found at the other end of a web search.
\section{A Basic Branching Example}
To get a basic understanding of how branching works in Git, let's start with a simple example. We'll assume that we have a single document called \texttt{doc\_a.txt}. It only contains two lines:
\begin{Verbatim}[frame=lines, numbers=left, xleftmargin=5mm, framesep=3mm, breaklines=true, label=\fbox{doc\_a.txt Initial Contents}]
This is line A1.
This is line A2.
\end{Verbatim}
\chapter{Remote Repositories}