I am working with gitlab. I have a yml file which runs the git command diff. This command shows the difference between the two branches. here is the yml file
image: bitnami/git:latest stages: - Test Test_stage: tags: - docker stage: Test script: - echo "test stage started" - git diff --color=always origin/main..pipeline_creation README.md | perl -wlne 'print $1 if /^\e\[32m\+\e\[m\e\[32m(.*)\e\[m$/' when i run this in the pipeline i am getting this error:
Created fresh repository. Checking out e33fa512 as pipeline_creation... Skipping Git submodules setup Executing "step_script" stage of the job script 00:00 $ echo "test stage started" test stage started $ git branch -a * (HEAD detached at e33fa51) remotes/origin/pipeline_creation $ git diff main..pipeline_creation README.md fatal: ambiguous argument 'main..pipeline_creation': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' Locally the command is working fine but when I run it in pipeline its not showing the expected result. Does someone know what am i doing wrong here?
pipeline_creationseems to be the branch that is checked out, are you sure your repo for the job contains aorigin/main? What is the output if you use the syntax without the "..", likegit diff --color=always origin/main pipeline_creation README.md?