Hi all, I have a (probably very noob-ish) Git workflow question. My Google-Fu is failing me today and I can’t find a simple answer to what I thought would be a simple and common action.
My situation is this: I originally did the fCC “Random Quote Generator” project using vanilla JS. Now that I’m learning React, I’d like to recreate the entire project in React, while leaving my original version untouched. This seems like it ought to be easy, right?
But when I go to my GitHub repo for the original project and click “Fork”, it won’t let me fork it:
So instead I made a new folder on my computer called “react-quote-generator”, copied the “clone” link to the original repo, and git-cloned it into the new folder. That worked fine, but now I’m wondering how to create a second repo on GitHub that contains all the code from my old version, as a kind of jumping-off point from which to start the new one. I’m hesitant to just mess around on my own, because I don’t want to accidentally overwrite the original project.
Thanks so much in advance for any help!
Some of this is preference. However, the company I work at uses https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow.
That may or may not be helpful.
To break down how to do this locally though – create a starter project and put it in a git repository. When you start a new project, it may look something like:
mkdir new-project && cd $_
git clone https://xyz/your/project.git .
rm -rf .git && git init
This will do the following:
- Create a new project folder and
cd into it
- Clone the starter project into the current directory
- Remove the
.git folder from the cloned project in the current directory (this will remove the git history associated with your starter project). Start a new git history for the current project.
Hopefully that answers your question! If not, feel free to let me know!
Thank you so much, that definitely gets me significantly further! Then the only thing I have left to do is start a new online repo that corresponds to my new project, I guess – so can I set it by using the “remote add origin” command?
Yeah – once you create a new repository online, then you can set a remote origin for the local project. If you create the repository on GitHub, it will provide you with the command-line instructions to do this.
Awesome. Many thanks for the advice, johnstonbl01!