Development/Tutorials/Git/Recipes: Difference between revisions

From KDE TechBase
(Created page with '===GIT/KDE useful recipes=== == Backporting fixes == Let's say you just fixed a bug in kde-apps and you commited it to the master and git reported it as commit id 0f601b3d28. Yo...')
 
(Replaced content with link to Community WIki.)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
===GIT/KDE useful recipes===
Updated version available at the [https://community.kde.org/Infrastructure/Git/Recipes Community wiki].
 
== Backporting fixes ==
Let's say you just fixed a bug in kde-apps and you commited it to the master and git reported it as commit id 0f601b3d28. You want now to get it backported to the latest released version.
 
When you issue:
<code>git branch -a</code>
you get
<code>
* master
  remotes/origin/4.6
  remotes/origin/HEAD -> origin/master
  remotes/origin/KDE/4.0
  remotes/origin/KDE/4.1
  remotes/origin/KDE/4.2
  remotes/origin/KDE/4.3
  remotes/origin/KDE/4.4
  remotes/origin/KDE/4.5
  remotes/origin/KDE/4.6
  remotes/origin/kdepim/enterprise-4.0.83
  remotes/origin/kdepim/enterprise-4.1
  remotes/origin/master
</code>
The red-colored lines are showing you the branches that are living into the main repository (you must have enabled git colors before this).
 
You need to backport to the last released version, which lives in the remotes/origin/KDE/4.6:
 
<code>
git checkout -b KDE/4.6 origin/KDE/4.6
</code>
This will get get you on the backport branch. Verify the diff between this old branch and the origin branch where you commited your fix :
<code>
git diff origin <fileYouModified>
</code>
 
To apply your fix, do this:
<code>
git cherry-pick 0f601b3d28
</code>
You just applied your fix (well, if you get merging errors, just fix them as usual). See it by yourself:
<code>git log</code>
 
Now push your changes:
<code>
git push
</code>
Don't forget to get back on the main branch:
<code>git checkout master</code>

Latest revision as of 12:18, 28 April 2019

Updated version available at the Community wiki.