-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Suggestion: Automatically create a new Git repository and add initial files #1244
Comments
Maybe it can be a flag so that it can be turned on/off as people prefers? Maybe something like |
We generally try to avoid flags. I think there was a discussion about initializing git earlier in #385. I’m down to do this by default if we also solve this:
So if we’re inside a Git/Hg project we shouldn’t try to initialize a new repo. |
That makes sense, the reason for my flag-idea was, just like you said, that you might want to use it in an existing repo. |
We should be able to detect this. After all, Git/Hg somehow detect they’re inside repos 😉 . |
That |
In the Angular CLI they run If already in a Git repo we could do a Not sure why I didn't see #385. I did search but did not come across that issue. From reading that I would not be in favor of adding a remote. Quite often I am just experimenting and even if I want to push it to a remote I might use BitBucket or some other alternative over GitHub. I would keep it very similar to what the Angular CLI does: Create a new repo if not already in one and add the generated code as the initial commit. From the last comment by @mareksuscak I am unsure how much work he already did do. Don't want to start two PR's that compete with each other. |
👍
@mareksuscak can you give us some context? |
I haven't done anything beyond examining how |
I think it's important to have an opt-out for this feature, because I wouldn't want the CLI making the first commit. |
@Timer Curious why? You could always amend it.. |
@gaearon main reason is that I want very specific files to be present in the first commit; namely simply a Not to mention I would like myself to be the root author; not the CLI. It seems like we're introducing much more complexity versus someone just typing |
Isn't it as easy as passing
That’s how I’d imagine it working. |
@gaearon I often utilize many different emails depending on the repository, so I'd be amending with additional flags such as It's not super easy to remove a file from the first commit, because you can't (as far as I know) rewind the commit via standard The process is more convoluted, requiring the user to run I would love for someone to improve my knowledge of |
@mareksuscak, Not in a hurry or so but I will go ahead and start this and create a PR. @Timer and @gaearon, Both the Ember and Angular CLI create a commit with the CLI as the author and the current user as the committer. I would argue that is correct as the user didn't write a single line of code yet, the CLI did that. But personally I don't care very much and would be happy with just the commit message stating that it was an initial commit from Create-React-App. @Timer, As far as I can tell you can remove files from the first commit without any problem. Just did a quick test after an |
Yes @mauricedb, but what if I want to remove a file from the initial commit while keeping it in my local directory? e.g. CLI commits In that scenario I'd just do |
@Timer, Right I misunderstood your goal. In that case I believe you are right and there is no simple way with git. I think the scenario you describe could be the easiest option. But it feels weird to delete a git repo so you can create one. |
I feel like people caring that much about what goes into initial commit is going to be a tiny minority of our users. But maybe I’m wrong. |
@gaearon, That is my gut feeling as well but have no data to back it up. There is a relatively simple workaround with the steps @Timer suggests. Personally I would not make this configurable through a command line option unless there was more demand for it. And adding an opt-out option should be easy in a future PR. |
I'm sure there will be very few complaints about it and I'm not trying to talk anyone out of implementing this. Please understand most of my comments were not an argument but simply an elaboration when asked. Anyway, I think this would be a good default and me removing |
I have the changes in a branch that should work but I am running into issues testing if it really works the way it is supposed to. I wanted to test using So I tried running it in a Linux Docker container but not having much luck there either. Using the following commands:
I see the following error:
Even though the file is there. My branch is here: https://github.com/mauricedb/create-react-app/tree/git-init |
Local workspace file ('angular.json') could not be found. |
One of the nice small things with the Angular CLI is that it automatically creates a new Git repository and adds the initial files to it as the initial commit after initializing a new project. It is not a major thing but it is something I find myself doing pretty much every time I create a new project, even if it is just for test purposes as it makes it easy to see what I changed.
Is this something other people would be interested in seeing me add?
The text was updated successfully, but these errors were encountered: