AppyPrinciplesGetting started
git's cheat sheet Merge a branch

This page is a cheat sheet mainly written for myself, and explains (to me, and possibly others, too) how to merge a branch into the main one.

Suppose you have a local git repository on your laptop, for the Sessions app, in /home/myself/projects/Sessions, configured on the main branch.

cd /home/myself/projects/Sessions

Type command:

git status

The result should sound like that (translated from git messages in french, so may be approximate):

On branch main
Your branch is up-to-date with 'origin/main'.
Nothing to validate, your branch is clean.

You know a friend of you dared to propose a branch named ultimate_fix. Even if the name of this branch has damaged your self-esteem, you decide to merge it. Before doing it, you can, in a first step, produce a diff between the main branch and his branch:

git diff main origin/ultimate_fix

For launching the merge, type the following commands.

git merge --no-commit --no-ff origin/ultimate_fix
git reset HEAD

After this, you should see your friends' modifications, in a not-committed way, just as if you had performed yourself modifications to the main branch. For example, if you want to see the state of your local repo:

git status

You could see something like:

On branch main
Your branch is up-to-date with 'origin/main'.
Unvalidated modifications:
    modified :
    modified :         tr/Custom-fr.po
    modified :         tr/Custom-nl.po
Unversioned files:
no modification was added at validation (use "git add" or "git commit -a")

Fine! You (I mean: I) can now review these changes, performing any modification on it before committing it (I am suspicious by nature).

In this precise case, one new file has been added, that I will add to the main branch:

git add pod/

Then, once everything will look fine, I will commit the changes on the main branch:

git commit -am "[Merge of branch ultimate_fix] I had to rewrite a lot of the proposed modifications, but finally, it works."
git push

Once this has been done, the branch can now be deleted.

git push origin --delete ultimate_fix