Convert a Cloned Repo into a New One on GitHub Codespaces
Scenario:
Suppose you clone a boilerplate project or open-source repository that you want to modify and make own. By removing .git
, you ensure that the project is no longer tied to the original repository. With the integrated terminal and Git tools in VS Code, you can perform all these steps without switching environments.
Why Git Clone in Virtual VS Code Works Well:
- Convenience: Virtual VS Code in GitHub lets you work directly in a cloud environment without setting up local tools.
- Easy Setup: Cloning the repository and managing
.git
can be done entirely from the integrated terminal in VS Code. - Clean Start: Removing
.git
allows you to discard the original history and start a new repository directly in virtual environment. - Direct Push to GitHub: You can push new repository directly to GitHub account without leaving the VS Code workspace.
Step-by-Step Guide for Virtual VS Code on GitHub:
Open the Virtual VS Code Workspace:
- Launch virtual workspace on GitHub
Clone the Original Repository:
Open the terminal in VS Code and clone the repository:
git clone <original-repo-url>
This will create a folder in workspace with the cloned repository.
Navigate into the Repository Folder:
Move into the cloned repository directory:
cd <repository-name>
Remove the
.git
Folder:Delete the
.git
directory to remove all Git history and configurations:rm -rf .git
Initialize a New Git Repository:
Start a fresh Git repository:
git init
Create a New Remote Repository on GitHub:
- Go to GitHub account and create a new, empty repository for this project.
Add New Remote Repository:
Add the new repository as the remote:
git remote add origin <your-new-repo-url>
Stage and Commit Files:
Stage all files:
git add .
Commit changes:
git commit -m "Initial commit to my new repository"
Push Changes to GitHub:
Push the code to new repository:
git push -u origin main
Replace
main
with default branch if different.