CircleCI checkout seems to do shallow checkout/clone


I am very new to CircleCI and I am trying to run a very simple shell script to find out the files that’s been changed in a branch since it was branched from the master.

In my config file, I have the following:
- checkout
- run:
command: |

In my, I run the following command:
git diff --name-only my_branch master

But it doesn’t show anything. I tried ssh into the virtual environment that the CircleCI checked out my repo into, and tried running all kinds of variations of git diff command. It doesn’t show anything. These commands return expected results in my local terminal though.

I am wondering if CircleCI does a shallow checkout by default? How do I solve this issue?

Thanks for your help!

As far I can tell, the provided checkout command does a full checkout. This was a bottleneck for our CI pipeline so I ended up making a shallow version of the same command – but I digress.

With my previous CI shenanigans, I have found that the working directory can be incorrectly set.

When you SSH into the container, are you in the appropriate directory? Can you provide snippets of your input + output?

Yes, I verified that I was in the appropriate directory. I found a way to solve it by changing my git diff command from the following:

git diff --name-only master
git diff --name-only origin/master

My best guess on the rational would be that git or CircleCI probably only fetches the brach in concern and creates a “dummy” master (if that makes any sense ) which could be just a copy of the branch. So it doesn’t show any diff when compared to the local master that was checked out.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.