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
Nene Barry
courses
Commits
82911dea
Verified
Commit
82911dea
authored
5 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
redo merge slide
parent
31c46285
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
2019/2019-09-24_advancedGitTraining/slides/merge.md
+20
-24
20 additions, 24 deletions
2019/2019-09-24_advancedGitTraining/slides/merge.md
with
20 additions
and
24 deletions
2019/2019-09-24_advancedGitTraining/slides/merge.md
+
20
−
24
View file @
82911dea
#
Theory:
Merging branches
# Merging branches
locally
*
Merge a branch into another one locally
*
Combines all the commits from a source branch onto a target branch
*
Combines all the commits from a source branch onto a target branch
*
In practice, this is very useful if you 'just want to try out something', or 'draft' something
# Example (1)
# Practical: Merging branches
*
Create a new branch from your
`myBranch`
branch:
*
Create a new branch from your own branch:
```
bash
```
bash
$
git checkout
-b
Feature1
$
git checkout myBranch
$
git checkout
-b
myNewBranch
```
```
*
Add two files to the Feature1 branch in two separate commits:
*
Add two files to the
`myNewBranch`
branch in two separate commits:
```
bash
$
echo
"Code that is merged into myBranch"
>
merge1.txt
$
git add merge1.txt
$
git commit
-m
"first commit to be merged"
```
```
bash
```
bash
$
echo
"Code that is merged into myBranch"
>
merge2.txt
$
echo
"# Trevor Westman"
>
trevor.md
$
git add merge2.txt
$
# add and commit the file trevor.md
$
git commit
-m
"second commit to be merged"
$
echo
"# Gustav Bergen"
>
gustav.md
$
# add and commit the file gustav.md
```
```
# Example (2)
*
Check the
`log`
of the
`myNewBranch`
and
`myBranch`
branches:
# Practical: Merging branches
*
Check the commit log of the myBranch and Feature1 branch
```
bash
```
bash
$
git log
$
git log myBranch
$
git log myNewBranch
```
```
*
Go to myBranch and merge the
Feature1
branch into it
*
Go to
`
myBranch
`
and merge the
`myNewBranch`
branch into it
```
bash
```
bash
$
git merge Feature1
$
git checkout myBranch
$
git merge myNewBranch
$
git log myBranch
```
```
*
This will move all changes made in the Feature1 branch
onto myBranch, effectively fusing the two together.
\ No newline at end of file
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