-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fatal: not a git repository when using checkout@v2 #363
Comments
I'm experiencing something similar with my action that tries to https://github.com/GMNGeoffrey/llvm-bazel/runs/1201180187 |
This allows us to trigger it on other events (e.g. a cron) to update for new LLVM commits without constantly clobbering the auto-integrate branch. Also switches to a personal access token (for a bot) so that there aren't issues pushing workflow files (which I ran into while testing) and so that the action can trigger webhooks for other automation (e.g. builds). I'm experiencing some intermittent failures that look like actions/checkout#363, but those were happening before this change as well. Tested: Ran on my fork: https://github.com/GMNGeoffrey/llvm-bazel/runs/1201208655 Second run: https://github.com/GMNGeoffrey/llvm-bazel/runs/1201226878
@DannyFriedmanQC can you attach your reference run (if possible)? I have seen such errors before, I think it is more like github action performance issue. |
Seeing the same. No https://github.com/HebaruSan/NetKAN/runs/1534015545?check_suite_focus=true
|
Just wanted to add my voice and say that I'm seeing the same thing. |
After reading #335, removing this fixed it for me: container:
image: ubuntu:latest Somehow this was causing the wrong version of |
Skipping submodules because they were downloaded previously
actions/checkout#363 And how they were downloaded previously it still should work
actions/checkout#363 And how they were downloaded previously it still should work
I'm also seeing this when using self-hosted runners on Windows Server. No .git directory is created. This causes all sorts of issues. Edit: Ah, I see there is a subtle warning message:
🤔 Edit: See #325 |
I don't understand it either, but removing my custom container from the job helped in my case, thanks! |
Removing
isn’t solution here. If you remove this code, workflow will be run on your self-hosted machine itself, not in the container. It seems to work because on your machine you must have newer version of Git.
according to this warning Git version should be higher than 2.18. So the real solution is to upgrade Git inside of your container’s image or, if version is already equal or higher than 2.18, add it to the PATH. Also there is another dirty workaround - after actions/checkout@v2 step run git init:
but this initialize empty repository - git commands will work, but there will be no information about remote repository. |
Hello ! I have same issue right now and I am not able to find a fix... it is killing me ! We first run the following :
The output is usr/bin/git. That tells us where git bin file is located (in folder located in usr/bin). Therefore if I run the following
and I see the response includes the folder usr/bin, then I am supposed I am already including Git into the path, ins't it? Or am I missing anything else ? Is there anything else to be done? My problem is that after verifying that git bin folder is included in path I am still having the issue. And the most surprising is that I do have a .git folder inside my project. Any help ?
|
@jorgesolebur Try |
What worked for me was, installing |
I'm also having this trouble, it's infuriating. A simple command like Some additional info:
|
My workaround was replacing |
@petronny your suggestion is working for lots of people, myself included. Care to explain why? |
Looks like this is the explanation ? #766 |
Just as an update, this error bugged me for quite a while just now. After testing all the suggestions here the only one that helped in the end was running this before my
|
+ Added a fix(?) for "fatal: not in a git directory" -> actions/checkout#363
For those of you using container images in their workflows, remember that many smaller container images do not have Git installed by default. So So the basic idea for container workflows should be:
The workflow should look like this (using Alpine Linux container here as an example): name: Alpine
on: push
jobs:
alpine:
runs-on: ubuntu-latest
container: alpine:latest
steps:
# Git is required so that actions/checkout does a proper Git checkout
# instead of using the GitHub REST API.
- name: Install Git in container
run: |
apk update
apk add git
# one time fix to avoid permission problems later on
git config --global --add safe.directory "$GITHUB_WORKSPACE"
# Checks-out the repository under $GITHUB_WORKSPACE.
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Now the git commands can be used.
- run: |
git status
git log -3
... |
So for those who are still stuck... I just discovered that the In V3, the CWD is left at the top level, so you have to |
@rustyhowell but no one has talked about the |
I think there are several issues being discussed in this issue. Some people do not have git installed in their runner, some people have older versions of git. My issue was neither of those. My issue was that I expected v3 to behave the same as v1 and they do not. Below is a snippet that shows that with V3, it clones the source into a subdir
But in the old V1, the checkout action leaves you in the
This was the issue for me. |
My point is, there may be other breaking changes in v2 or v3 that are not well documented. For me, it was the |
This issue feels like the twilight zone ^^. |
@seyuf I disagree with your assessment. Rusty came here probably because he faced the same error message pasted in the title of the github issue. The fact that some people have already stated the same workaround many times and that this workaround may have worked for the original reporter doesn't mean that this github issue should be closed, because it is just a workaround, and because that workaround may not be helpful to other people that may be facing the same error message (even if the issue is not the same one as the original reporter's issue, albeit receiving same error). |
@knocte I suggested closing the issue as i m afraid this will never be fixed. As the range it is covering is too wide. |
I am trying to run git commands in an action using checkout@v2 but I am getting the error
fatal: not a git repository
My yaml looks like the following
The text was updated successfully, but these errors were encountered: