Skip to content

Commit b4668b1

Browse files
authored
Merge pull request #42 from aobolensk/01-update-2025-2
Add section about updating feature branch & commit cherry-pick to 01-git
2 parents f6d64b9 + 6833cf1 commit b4668b1

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

01-git/01-git.tex

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,66 @@ \section{Advanced Git Operations}
307307
\end{itemize}
308308
\end{frame}
309309

310+
\begin{frame}{Updating Feature Branch: Why}
311+
\footnotesize
312+
Keeping your feature branch current with \texttt{main} helps to:
313+
\begin{itemize}
314+
\item Reduce integration pain and surface conflicts early
315+
\item Ensure CI runs against the latest base code
316+
\item Keep PRs small, focused, and easy to review
317+
\item Avoid long-lived drift that complicates release
318+
\end{itemize}
319+
\end{frame}
320+
321+
\begin{frame}{Update via Merge}
322+
\footnotesize
323+
Preserve history by merging the latest \texttt{main} into your feature.
324+
\begin{block}{Commands}
325+
\texttt{git fetch origin}\newline
326+
\texttt{git checkout <feature>}\newline
327+
\texttt{git merge origin/main}
328+
\end{block}
329+
\begin{itemize}
330+
\item Pros: no history rewrite; safe for shared branches
331+
\item Cons: adds merge commits; history may be noisier
332+
\end{itemize}
333+
\end{frame}
334+
335+
\begin{frame}{Update via Rebase}
336+
\footnotesize
337+
Create a linear history by replaying your work on top of \texttt{main}.
338+
\begin{block}{Commands}
339+
\texttt{git fetch origin}\newline
340+
\texttt{git checkout <feature>}\newline
341+
\texttt{git rebase origin/main}
342+
\end{block}
343+
If conflicts: fix files, \texttt{git add <file>}, then \texttt{git rebase --continue}. To cancel: \texttt{git rebase --abort}.
344+
\begin{itemize}
345+
\item Pros: cleaner, linear history; easier to review
346+
\item Cons: rewrites commits; avoid on shared/public branches
347+
\end{itemize}
348+
\end{frame}
349+
350+
\begin{frame}{Cherry-pick a Commit}
351+
\footnotesize
352+
Apply (pick) an existing commit onto your current branch without merging entire branches.
353+
\begin{itemize}
354+
\item Common uses: bring a specific fix, backport a change.
355+
\item Usage:
356+
\begin{block}{Commands}
357+
\texttt{git cherry-pick <commit>} --- Apply a single commit\newline
358+
\texttt{git cherry-pick A..B} --- Apply a range (excludes A, up to B)\newline
359+
\texttt{git cherry-pick <c1> <c2>} --- Apply multiple commits
360+
\end{block}
361+
\item Useful flags:
362+
\begin{block}{Flags}
363+
\texttt{-x} --- Append ``cherry picked from commit hash (SHA)'' to the message\newline
364+
\texttt{-n} (\texttt{--no-commit}) --- Do not create a commit; leave changes staged
365+
\end{block}
366+
\end{itemize}
367+
It is called ``cherry-picking'' because you are selecting (or ``picking'') specific commits from one branch to apply to another, much like picking cherries from a tree.
368+
\end{frame}
369+
310370
\begin{frame}{Handling Merge Conflicts}
311371
\textbf{When Conflicts Occur}:
312372
\begin{itemize}

01-git/01-git.toc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
\beamer@sectionintoc {3}{What is Git?}{9}{0}{3}
44
\beamer@sectionintoc {4}{Basic Git commands}{11}{0}{4}
55
\beamer@sectionintoc {5}{Advanced Git Operations}{24}{0}{5}
6-
\beamer@sectionintoc {6}{Git workflows overview}{27}{0}{6}
6+
\beamer@sectionintoc {6}{Git workflows overview}{31}{0}{6}

0 commit comments

Comments
 (0)