Search code examples
gitversion-controlgitlab

gitlab: history of commits are available after merge request


I have forked a project and doing some changes on it during several commits. I want to know if I submit a merge request, history of all commits are available to maintainer or not?

I'm looking for a solution which all commits are aggregated as one commit and I don't know if it does happen during merge request or not? This is because I have do some trial-n-errors and I don't like that these trial-n-errors be visible to project maintainer.


Solution

  • Yes, if you push your branch, all the history will be there. You can either

    #1 Squash all your commits before you push your branch: see Git: How to squash all commits on branch how to do this

    or

    #2 Squash all your commits on merge: newer versions of gitlab have a feature that if you merge to master, all your commits will be automatically squashed before the actual merge: Gitlab Squash

    See https://docs.gitlab.com/ee/user/project/merge_requests/squash_and_merge.html for more information.

    Personally I have done #1 before Gitlab could squash automatically. Now I do #2 all the time. If you don't want the history of all your commits available to the maintainer, you should do #1. Otherwise #2 will work just fine and the end result will be the same: One single commit for your changes.