1

Error: This command requires clean working and staging areas, including no untracked files. Modify .gitignore and/or add/commit first, or add the --no-commit option.

What if I don't want to commit code yet

How to resolve this issue

2 Answers 2

1

You may already be inside a git folder when doing this command. In general it is best to use forge outside of another git folder (this is what is meant with "clean").

Use the following command to use foundry without git:

forge init --no-git or forge init --no-commit

I'm assuming you're using forge init. In case you want to use forge install use the following commands forge install --no-git or forge install --no-commit but do note that normally dependencies are installed as git submodules.

The foundry book is a great resource, I recommend browsing for any general issue.

Source:

https://book.getfoundry.sh/reference/forge/forge-init?highlight=--no-git#options

https://book.getfoundry.sh/reference/forge/forge-install

2
  • Thanks for response, but I have question I am working on smart contract and I want to install something say, forge install transmissions11/solmate and it throws that error. yes, I am inside the root of project. If I remove all changes and do install all work fine. it's only when there is uncommitted changes . What am I doing wrong?
    – Error404
    Commented Mar 23, 2023 at 15:28
  • If you already are in the root of a project, you need to be in a "clean" environment. This means there is not .git or .gitignore files in the folder structure above. Do you have such files in folders that may be above it ? Commented Mar 23, 2023 at 22:22
1

If you are trying to install dependencies in a foundry project which is also a git repository, your best option is forge install --no-commit which installs the dependency as a git submodule.

There is also forge install --no-git but I would use that only if I have a specific reason to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.