Skip to content

ctf challenge add fails #173

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

Open
misogihagi opened this issue Mar 26, 2025 · 7 comments
Open

ctf challenge add fails #173

misogihagi opened this issue Mar 26, 2025 · 7 comments

Comments

@misogihagi
Copy link

Hello. I am new to ctfcli, I just did ctf init and ctf challenge add https://github.com/misogihagi/my-ctf-challenges.git andgot the following error:

fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: working tree has modifications.  Cannot add.
Could not add the challenge repository. Please check git error messages above.   

Is this a known bug?

@ColdHeat
Copy link
Member

I believe you have changes in your local repository which is causing the errors you're seeing. Try running the command after committing the changes and then it should work.

@misogihagi
Copy link
Author

The above was running on raspberrypi, but I tried running it on docker as well.
And the result is as follows, it doesn't work either way

$ docker run -it python:3.11 bash
root@56cbc83bd04e:/# pip install ctfcli
~~~
root@56cbc83bd04e:/# cd
root@56cbc83bd04e:~# ctf init
Please enter CTFd instance URL: http://127.0.0.1
Please enter CTFd Admin Access Token: xxxx
Do you want to continue with http://127.0.0.1 and xxxx [Y/n]: 
Creating a git repo in /root
hint: Using 'master' as the name for the initial branch. This default branch name                                                           
hint: is subject to change. To configure the initial branch name to use in all                                                              
hint: of your new repositories, which will suppress this warning, call:                                                                     
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and                                                                     
hint: 'development'. The just-created branch can be renamed via this command:                                                               
hint: 
hint:   git branch -m <name>
Initialized empty Git repository in /root/.git/
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'root@56cbc83bd04e.(none)')
root@56cbc83bd04e:~# ctf challenge add https://github.com/misogihagi/my-ctf-challenges.git
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: working tree has modifications.  Cannot add.
Could not add the challenge repository. Please check git error messages above.                      

@VaiTon
Copy link
Contributor

VaiTon commented Apr 7, 2025

The clue here is:

fatal: unable to auto-detect email address (got 'root@56cbc83bd04e.(none)')

git is unable to detect an email address, and can't make the initial commit. When you try to add the challenge it detects that the working tree has modifications and fails.

@misogihagi
Copy link
Author

I certainly don't have a git setup...
Why do you use git in ctfcli?

@VaiTon
Copy link
Contributor

VaiTon commented Apr 12, 2025

@misogihagi, from the README:

Ctfcli turns the current folder into a CTF event git repo. It asks for the base url of the CTFd instance you're working with and an access token.

@misogihagi
Copy link
Author

@VaiTon , thants forinformation.
I understand using git to do git clone though
For example, when uploading a challenge from a different directory, when setting up from the GUI, git should not to be necessary.
Why do we need git in the first place?

@ColdHeat
Copy link
Member

git is used by ctfcli to support versioning of challenges. CTFd itself does not do versioning so we use git to track how challenges change. We use a bit of a strange setup (that I doubt people will want to replicate) but I don't think using git to manage challenges is uncommon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants