how can I change this message when I execute this git command in a GitLab repository:
git push --set-upstream origin test-branch
The origin message:
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for test-branch, visit:
remote: https://example.org/customer/name/project/-/merge_requests/new?merge_request[source_branch]=test-branch
remote:
To git.example.org/customer/name/project.git
* [new branch] test-branch -> test-branch
branch 'test-branch' set up to track 'origin/test-branch'.
The message I want to achieve:
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for test-branch, visit:
remote: https://example.org/customer/name/project/-/merge_requests/new?merge_request[source_branch]=test-branch
remote:
remote: To create a merge request for test-branch with target branch 'staging', visit:
remote: https://example.org/customer/name/project/-/merge_requests/new?merge_request[source_branch]=test-branch&merge_request%5Btarget_branch%5D=staging
remote:
remote: To create a merge request for test-branch with target branch 'main', visit:
remote: https://example.org/customer/name/project/-/merge_requests/new?merge_request[source_branch]=test-branch&merge_request%5Btarget_branch%5D=main
remote:
To git.example.org/customer/name/project.git
* [new branch] test-branch -> test-branch
branch 'test-branch' set up to track 'origin/test-branch'.
Thanks in advance!
Per How to add message with link to new pull request page after pushing branch to GitHub?, this messaging is coming from GitLab via the post-receive
Git hook, as documented here. This is a server-side hook, so you need to modify files on the GitLab server itself.
My direct expertise ends about here, and I'd have to make educated guesses with you. You want to either modify the actual hook used in GitLab or convince it to additionally call another. I would personally be nervous about losing whatever else the existing hook is doing.
The simplest path that I would try first is to check your server repository for a /hooks directory and see if it has an existing post-receive file you can modify. The questioner in How can I add hooks to gitlab? might have managed this successfully.
Another option is that it appears that GitLab supports custom hooks. This is documented here, although an older version seems more readable, if possibly dated. This looks more involved, but possibly more correct.
Adding the git-post-receive
tag to the question might attract better answers.
See also Understanding Git Hook - post-receive hook and How to setup Gitlab with post-receive hook? (serverfault)