I'm not quite sure if this is a bug or the expected behavior: cargo creates a new git repo when creating a new project in a subdirectory of a current git repository. When creating a new project at the top level of a git repo, however, it does detect the git repo and does not create a new one,
# create in project at root of git repo
git init # creates /repo/.git
cargo new foo # no git repo created inside /repo/foo
# create project in subdir of git repo
git init # creates /repo2/.git
cargo new foo/bar/baz # initializes new git repo at /repo2/foo/bar/baz/.git
In the second group of commands above, shouldn't cargo detect it is inside a git repo already and not create
When you run
cargo new it creates a
.gitignore file, you might not be able to find it because some settings on some devices hide files that begin with a (.), but it creates that, it also might be because running git init turns the entire current file path into a repository, I think the devs of git new it would be way faster to add that, anyway, your just gonna have to open up git bash and undo that or delete the
.gitignore files, and cut the files off from github. Plus you don't really need to make it a repository when you first start making a projects, instead when your done with your project, make a repository, select that as your current, then add the files you made to the commit with git commands
git commit -m '<your commit message>' then type
git push and you should be done. Note: if the files are too large to push to github or just work with at all when using git, install git lfs (
git lfs install).
I don't know how to stop git but I think you can find out how to stop this behaviour somewhere on git's official website. I think your allowed to tweak git's settings.
also rust's new update was recently released Announcing Rust 1.68.2 | Rust Blog
----in which they added----
Rust 1.68.2 addresses GitHub's recent rotation of their RSA SSH host key, which happened on March 24th 2023 after their previous key accidentally leaked:
If you are having errors I suggest you upgrade to rust 1.68.2
@funnimonkedev Your answers seem to be missing the point of this question a bit.
@aryzing I can reproduce this behavior, and I agree with the assessment that it’s a bit strange/inconsistent behavior. If there doesn’t exist one already, I suppose opening a github issue might be reasonable.
Edit: On the question of whether this might be “a bug or the expected behavior”: Given that it’s not documented anywhere I can find, I’d say it’s probably a bug. For example here the claim is simply “If the directory is not already in a VCS repository, then a new repository is created”.
@funnimonkedev there doesn't seem to be a workable relationship between your answer and my question. Anything I could clarify?
@steffahn great, very useful, thanks. I'll open an issue.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.