Reputation: 652
On a daily basis I am working with GitLab with following workflow:
feature
branch from main
branchfeature
branchfeature
into main
) via GitLab GUI using squash
feature:
main
branch tree (from IntellJ IDEA):
I have tried to achieve the same on my testing repository using command line only but with no success so far. I have tried (on feature
branch) interactive rebase as well as soft reset with force push but it always results as a 'single line tree'. Example after two separate merges from feature
into main
:
git checkout main
git merge <feature_branch_name>
Does anyone know how it works under the hood (command by command)? According to this issue it uses soft reset but it's only someone's guess. I was also searching in official documentation but with no success so far. Thanks in advance!
Upvotes: 0
Views: 418
Reputation: 7632
Simply use merge without fast-forward:
git merge --no-ff
https://git-scm.com/docs/git-merge#Documentation/git-merge.txt---no-ff
This will create the merge as you want
You can make it the default
Put in your config file ( $HOME/.gitconfig
on linux)
[merge]
ff = no
commit = no
You can also use git-config to do this:
git config --global merge.commit no
git config --global merge.ff no
Upvotes: 1