Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
courses
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Todor Kondic
courses
Commits
75163cf0
Verified
Commit
75163cf0
authored
5 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
adapt the slides for cherr-picking
parent
c3ce4d6a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
2019/2019-09-24_advancedGitTraining/slides/chPick.md
+25
-27
25 additions, 27 deletions
2019/2019-09-24_advancedGitTraining/slides/chPick.md
2019/2019-09-24_advancedGitTraining/slides/img/cherryPick.png
+0
-0
0 additions, 0 deletions
.../2019-09-24_advancedGitTraining/slides/img/cherryPick.png
with
25 additions
and
27 deletions
2019/2019-09-24_advancedGitTraining/slides/chPick.md
+
25
−
27
View file @
75163cf0
#
Theory: Git
Cherry-picking
# Cherry-picking
*
It enables the user to pick specific commits from a list of commits.
*
Cherry-pick allows to pick one (or more) specific commits from a list of commits.
*
Cherry picking only picks the selected commit(s), not everything up to that commit.
Careful!
Cherry picking only picks the selected commit,
not everything up to that commit.
<div
style=
"top: 15em; left: 30%; position: absolute;"
>
<img
src=
"slides/img/cherryPick.png"
>
<div
style=
"top: 8em; left: 25%; position: absolute;"
>
<img
src=
"slides/img/cherryPick.png"
height=
500px
>
</div>
#
Practical: Git Cherry-picking
#
Example (1)
*
In your branch, create and commit a reference file
*
In your branch
`myBranch`
, create and commit a reference file
`references.md`
:
```
bash
$
echo
"This is the start of a commit chain"
>
reference.txt
$
git add
reference
.txt
$
git commit origin myBranch
$
git checkout myBranch
$
echo
"# References"
>
reference
s.md
$
# add and commit the file references.md
```
*
Create and commit two files in the develop branch
*
Create and commit two files in the
`
develop
`
branch
```
bash
$
echo
"This is a commit to keep"
>
keep.txt
$
git add keep.txt
$
git commit origin develop
$
echo
"Ignore this commit"
>
ignore.txt
$
git add ignore.txt
$
git commit origin develop
$
echo
"# Venue details"
>
location.md
$
# add and commit the file location.md
$
echo
"# Speakers"
>
speakers.md
$
# add and commit the file speakers.md
```
#
Practical: Git Cherry-picking
#
Example (2)
*
Check the commit reference of the two commits in develop
*
Chose the commit to keep and add it to your branch
*
Check the
`log`
and note down the
`SHA1`
of the commits you want to cherry-pick. Then:
```
bash
$
git checkout myBranch
$
git cherry-pick <
commit reference
>
$
git cherry-pick <
SHA1
>
```
*
Check the log again and see if the changes were applied correctly
```
bash
$
git show <newSHA1>
```
*
Repeat for the second commit
*
p
ush the changes to
the develop b
ranch
*
P
ush the changes to
`myB
ranch
`
```
bash
$
git push origin myBranch
-f
$
git push origin myBranch
```
*
The
`-f`
flag is used to force push into develop
\ No newline at end of file
*
Note that the
`-f`
flag is not needed to force push (no history has been rewritten)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
2019/2019-09-24_advancedGitTraining/slides/img/cherryPick.png
+
0
−
0
View replaced file @
c3ce4d6a
View file @
75163cf0
19.5 KiB
|
W:
|
H:
31.1 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment