<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Git_-_Branching_and_Merging</id>
	<title>Git - Branching and Merging - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Git_-_Branching_and_Merging"/>
	<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Git_-_Branching_and_Merging&amp;action=history"/>
	<updated>2026-05-13T06:50:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://training-course-material.com/index.php?title=Git_-_Branching_and_Merging&amp;diff=88848&amp;oldid=prev</id>
		<title>Pszlachta1 at 10:21, 3 June 2025</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Git_-_Branching_and_Merging&amp;diff=88848&amp;oldid=prev"/>
		<updated>2025-06-03T10:21:22Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:21, 3 June 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l26&quot;&gt;Line 26:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 26:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Dealing with Branches and Tags ⌘==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Dealing with Branches and Tags ⌘==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;source &lt;/del&gt;lang = &quot;bash&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight &lt;/ins&gt;lang = &quot;bash&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  git clone git://git.kernel.org/pub/scm/git/git.git&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  git clone git://git.kernel.org/pub/scm/git/git.git&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  git branch&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  git branch&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l35&quot;&gt;Line 35:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 35:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  git checkout v1.7.4&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  git checkout v1.7.4&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  git branch&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  git branch&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;source&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Creating Branches ⌘==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Creating Branches ⌘==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pszlachta1</name></author>
	</entry>
	<entry>
		<id>https://training-course-material.com/index.php?title=Git_-_Branching_and_Merging&amp;diff=87648&amp;oldid=prev</id>
		<title>Lsokolowski1: /* Rebasing ⌘ */</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Git_-_Branching_and_Merging&amp;diff=87648&amp;oldid=prev"/>
		<updated>2023-03-17T10:44:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Rebasing ⌘&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Git|081]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;slideshow style=&amp;quot;nobleprog&amp;quot; headingmark=&amp;quot;⌘&amp;quot; incmark=&amp;quot;…&amp;quot; scaled=&amp;quot;true&amp;quot; font=&amp;quot;Trebuchet MS&amp;quot; &amp;gt;&lt;br /&gt;
;title: Git for Users Training Course&lt;br /&gt;
;author: Bernard Szlachta (NobleProg Ltd)&lt;br /&gt;
&amp;lt;/slideshow&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Branching and Merging ⌘==&lt;br /&gt;
 git branch&lt;br /&gt;
list all branches&lt;br /&gt;
 git branch &amp;lt;branch&amp;gt;&lt;br /&gt;
create a new branch named &amp;lt;branch&amp;gt;, referencing the same point in history as the current branch&lt;br /&gt;
 git branch &amp;lt;branch&amp;gt; &amp;lt;start-point&amp;gt;&lt;br /&gt;
create a new branch named &amp;lt;branch&amp;gt;, referencing &amp;lt;start-point&amp;gt; (branch, tag or commit)&lt;br /&gt;
 git branch -d &amp;lt;branch&amp;gt;&lt;br /&gt;
delete the branch &amp;lt;branch&amp;gt;; if the branch you are deleting points to a commit which is not reachable from the current branch, this command will fail with a warning.&lt;br /&gt;
 git branch -D &amp;lt;branch&amp;gt;&lt;br /&gt;
* forces to do even branch points to a commit not reachable from the current branch&lt;br /&gt;
* failed experiment branches&lt;br /&gt;
* use only for changes in your repository&lt;br /&gt;
 git checkout &amp;lt;branch&amp;gt;&lt;br /&gt;
switch to the &amp;lt;branch&amp;gt;&lt;br /&gt;
 git checkout -b &amp;lt;new&amp;gt; &amp;lt;start-point&amp;gt;&lt;br /&gt;
create a new branch &amp;lt;new&amp;gt; referencing &amp;lt;start-point&amp;gt;, and check it out&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Dealing with Branches and Tags ⌘==&lt;br /&gt;
&amp;lt;source lang = &amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 git clone git://git.kernel.org/pub/scm/git/git.git&lt;br /&gt;
 git branch&lt;br /&gt;
 git branch -r&lt;br /&gt;
 git tag&lt;br /&gt;
 git checkout maint&lt;br /&gt;
 git branch&lt;br /&gt;
 git checkout v1.7.4&lt;br /&gt;
 git branch&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating Branches ⌘==&lt;br /&gt;
 cp repo/ repo.bak -R; cp central/ central.bak -R&lt;br /&gt;
Create new branch and switch working copy&lt;br /&gt;
 git branch experiment&lt;br /&gt;
 git checkout experiment&lt;br /&gt;
 git checkout -b experiment&lt;br /&gt;
&lt;br /&gt;
== Merging ⌘==&lt;br /&gt;
* switch to experiment&lt;br /&gt;
* modify the afile.txt&lt;br /&gt;
 git commit -a&lt;br /&gt;
 git checkout master&lt;br /&gt;
 modify afile.txt (different part)&lt;br /&gt;
 git commit -a&lt;br /&gt;
 gitk --all&lt;br /&gt;
 git branch&lt;br /&gt;
 git merge experiment&lt;br /&gt;
 gitk --all&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Exercise (REmoving) ⌘==&lt;br /&gt;
# Create branch v2.x&lt;br /&gt;
# Modify a couple of files in the branch&lt;br /&gt;
# Merge the branch with master&lt;br /&gt;
# Remove the branch v2.x&lt;br /&gt;
&lt;br /&gt;
== Exercises (remote branching) ⌘==&lt;br /&gt;
* Create a branch “quickfix” from a master branch&lt;br /&gt;
 git checkout master&lt;br /&gt;
 git checkout -b quickfix&lt;br /&gt;
* create quickfix.txt in quickfix branch and commit&lt;br /&gt;
 touch quickfix.txt&lt;br /&gt;
 git add quickfix.txt&lt;br /&gt;
 git commit -m &amp;quot;quickfix&amp;quot;&lt;br /&gt;
* switch to master&lt;br /&gt;
 git checkout master&lt;br /&gt;
* Commit 2 changes into the master branch&lt;br /&gt;
 echo 1 &amp;gt;&amp;gt; afile.txt; git commit -a -m &amp;quot;change1&amp;quot;&lt;br /&gt;
 echo 2  &amp;gt;&amp;gt; afile.txt; git commit -a -m &amp;quot;change2&amp;quot;&lt;br /&gt;
* switch back to quickfix&lt;br /&gt;
 git checkout quickfix&lt;br /&gt;
* analyse situation in &lt;br /&gt;
 gitk --all&lt;br /&gt;
* Push the quickfix to the production&lt;br /&gt;
 git push origin quickfix&lt;br /&gt;
* On production&lt;br /&gt;
 git fetch origin quickfix&lt;br /&gt;
 git branch -a&lt;br /&gt;
 git checkout origin/quickfix -b quickfix&lt;br /&gt;
* On Devel&lt;br /&gt;
 merge quickfix into masterbranch&lt;br /&gt;
* delete quickfix branch&lt;br /&gt;
&lt;br /&gt;
== Reverting Merges ⌘==&lt;br /&gt;
Adding commit with reverted changes&lt;br /&gt;
 git revert&lt;br /&gt;
Before Committing&lt;br /&gt;
 git reset --hard HEAD&lt;br /&gt;
After Committing&lt;br /&gt;
 git reset --hard ORIG_HEAD&lt;br /&gt;
use only if you committed it only to your private repo&lt;br /&gt;
&lt;br /&gt;
== Rebasing ⌘==&lt;br /&gt;
[[File:Git-rebasing1.png|260px]] [[File:Git-rebasing2.png|320px]]  [[File:Git-rebasing3.png|320px]]&lt;br /&gt;
&lt;br /&gt;
 git checkout -b mywork origin&lt;br /&gt;
 echo mywork changes &amp;gt;&amp;gt; afile.txt&lt;br /&gt;
 git commit -a&lt;br /&gt;
 git checkout master&lt;br /&gt;
 echo some new func &amp;gt;&amp;gt; afile_master.txt&lt;br /&gt;
 git add afile_master.txt&lt;br /&gt;
 git commit&lt;br /&gt;
 gitk --all&lt;br /&gt;
 git rebase mywork&lt;br /&gt;
 gitk --all&lt;br /&gt;
 git prune&lt;br /&gt;
 gitk --all&lt;br /&gt;
&lt;br /&gt;
== Exercise ⌘==&lt;br /&gt;
# Create a branch “quickfix”&lt;br /&gt;
# add a couple of changes afile.txt in quickfix branch&lt;br /&gt;
# switch to master&lt;br /&gt;
# Commit 2 changes into the master branch&lt;br /&gt;
# switch back to quickfix&lt;br /&gt;
# analyse situation in gitk --all&lt;br /&gt;
# rebase quickfix branch to master&lt;br /&gt;
# analyse situation in gitk -all&lt;br /&gt;
# prune dangling objects&lt;br /&gt;
# gitk --all&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Cherry Picking ⌘==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; width=&amp;quot;600px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Git-cherry-picking.jpg|250px]][[File:Git-cherry.png]]&lt;br /&gt;
|| &lt;br /&gt;
 touch afile.txt&lt;br /&gt;
 git add afile.txt&lt;br /&gt;
 git commit -m &amp;quot;new filo&amp;quot;&lt;br /&gt;
 git checkout -b exp&lt;br /&gt;
 echo Not Cherry1 &amp;gt;&amp;gt; afile.txt &lt;br /&gt;
 git commit -a -m NotCherry1&lt;br /&gt;
 echo Cherry &amp;gt;&amp;gt; afile.txt &lt;br /&gt;
 git commit -a -m Cherry&lt;br /&gt;
 echo Not Cherry2 &amp;gt;&amp;gt; afile.txt &lt;br /&gt;
 git commit -a -m NotCherry2&lt;br /&gt;
 git checkout master&lt;br /&gt;
 echo masterchange &amp;gt;&amp;gt; afile_master.txt &lt;br /&gt;
 git add afile_master.txt&lt;br /&gt;
 git commit -a -m &amp;quot;Master Change&amp;quot;&lt;br /&gt;
 git log exp&lt;br /&gt;
 git cherry-pick 3c8f&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Stashing ⌘==&lt;br /&gt;
* git-stash to save the current state of your work&lt;br /&gt;
* git stash save &amp;quot;work in progress for foo feature&amp;quot;&lt;br /&gt;
* echo “bug fix” &amp;gt;&amp;gt; afile.txt&lt;br /&gt;
* git commit -a -m &amp;quot;fixed the bug&amp;quot;&lt;br /&gt;
* git stash pop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Workflow Structure ⌘==&lt;br /&gt;
[[File:Git-wf-structure.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Combining Commits ⌘==&lt;br /&gt;
# Version upto 1.6 &lt;br /&gt;
 git format-patch  v1.0..HEAD&lt;br /&gt;
 git reset v1.0&lt;br /&gt;
 git apply *.patch&lt;br /&gt;
 git commit&lt;br /&gt;
&lt;br /&gt;
# Version 1.7 onwords&lt;br /&gt;
  git reset v1.0&lt;br /&gt;
  git commit&lt;/div&gt;</summary>
		<author><name>Lsokolowski1</name></author>
	</entry>
</feed>