Information

Author(s) Mathieu Jadin
Deadline No deadline
Submission limit No limitation

Sign in

Git: Merge branches

In the previous exercise, you learned how to create and work with different branches.

The main concept behind branches is to merge the modifications made in one branch into the main branches once you tested your changes.

https://inginious.org/course/git/git-branch-merge/git-before-merge.svg

The profile branch is ready to be merged with the master branch. To do so, you need to set yourself on the branch master (with checkout) and use the command git merge. The merging of two branches works similarly to a pull from the remote history. If there are no modifications on the master branch (as here), the pointer of the branch is just moved. If there are compatible modifications on the master branch, a merge commit is automatically created. If there are incompatible changes, the conflicts will have to be solved just as in the exercise on conflicts solving.

https://inginious.org/course/git/git-branch-merge/git-after-merge.svg

Then, as usual, you need to push the local history of the branch master to the remote history.

https://inginious.org/course/git/git-branch-merge/git-after-push.svg

You have to use git merge <src-branch-name> on the destination branch.


Download the archive which already contains a cloned repository in the subfolder clone. The repository is already in the state described by the first image of this exercise. You need to modify the repository such as it matches the last image.

Afterwards, zip the whole folder and upload it.

Note that the remote repository in this exercise is not on GitHub or Bitbucket but inside the folder bare.git of the archive. Your submission needs to respect the following hierarchy:

git-branch-merge/
├── bare.git/
|   └── [...]
└── clone/
    └── [...]

Max file size: 1.0 MiB
Allowed extensions: .zip