Development/Tutorials/Git/Recipes: Difference between revisions
Neverendingo (talk | contribs) m (Text replace - "</code>" to "</syntaxhighlight>") |
Neverendingo (talk | contribs) m (Text replace - "<code>" to "<syntaxhighlight lang="bash">") |
||
Line 7: | Line 7: | ||
When you issue: | When you issue: | ||
< | <syntaxhighlight lang="bash">git branch -a</syntaxhighlight> | ||
you get | you get | ||
< | <syntaxhighlight lang="bash"> | ||
* master | * master | ||
remotes/origin/4.6 | remotes/origin/4.6 | ||
Line 28: | Line 28: | ||
You need to backport to the last released version, which lives in the remotes/origin/KDE/4.6: | You need to backport to the last released version, which lives in the remotes/origin/KDE/4.6: | ||
< | <syntaxhighlight lang="bash"> | ||
git checkout -b KDE/4.6 origin/KDE/4.6 | git checkout -b KDE/4.6 origin/KDE/4.6 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
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 : | 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 : | ||
< | <syntaxhighlight lang="bash"> | ||
git diff origin <fileYouModified> | git diff origin <fileYouModified> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
To apply your fix, do this: | To apply your fix, do this: | ||
< | <syntaxhighlight lang="bash"> | ||
git cherry-pick 0f601b3d28 | git cherry-pick 0f601b3d28 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
You just applied your fix (well, if you get merging errors, just fix them as usual). See it by yourself: | You just applied your fix (well, if you get merging errors, just fix them as usual). See it by yourself: | ||
< | <syntaxhighlight lang="bash">git log</syntaxhighlight> | ||
Now push your changes: | Now push your changes: | ||
< | <syntaxhighlight lang="bash"> | ||
git push | git push | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Don't forget to get back on the main branch: | Don't forget to get back on the main branch: | ||
< | <syntaxhighlight lang="bash">git checkout master</syntaxhighlight> |
Revision as of 18:53, 29 June 2011
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. You want now to get it backported to the latest released version.
When you issue:
git branch -a
you get
* 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
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:
git checkout -b KDE/4.6 origin/KDE/4.6
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 :
git diff origin <fileYouModified>
To apply your fix, do this:
git cherry-pick 0f601b3d28
You just applied your fix (well, if you get merging errors, just fix them as usual). See it by yourself:
git log
Now push your changes:
git push
Don't forget to get back on the main branch:
git checkout master