Horje
How To Change The Root Folder Of Your Git Repo?

Changing the root folder of your Git repository involves moving the .git directory to a new location and ensuring that your project’s files are in the correct structure relative to this new root.

To change the root folder of your Git repository, you essentially need to move the .git directory to the desired new root location. Here are the steps to do this:

Method 1: Moving the Repository to a New Root Folder

Move the .git directory from the current root folder to the new root folder.

cd GFG
mv .git GFG1

Screenshot-(334)

Before Moving .git Folder

Screenshot-(336)

After Moving the .git folder

Method 2: Using a New Repository Initialization

Step 1: Create a new repository

Screenshot-(333)

Navigate to your new root folder and initialize a new Git repository.

cd GFG1
git init

Step 2: Add your files and commit

Add your existing files to this new repository.

git add .
git commit -m "Initial commit in new root"

Step 3: Link to the remote repository

If you have a remote repository (like on GitHub or GitLab), you need to add it to your new repository.

git remote add origin https://github.com/bishal1289/Hello__World.git
git push -u origin main
Screenshot-(337)

How To Change The Root Folder Of Your Git Repo?




Reffered: https://www.geeksforgeeks.org


Git

Related
How To Get Changes From Master Into a Branch in Git? How To Get Changes From Master Into a Branch in Git?
How To Remove Version Tracking From Project Cloned From Git? How To Remove Version Tracking From Project Cloned From Git?
Difference Between "git commit" and "git push"? Difference Between "git commit" and "git push"?
How To Stop .gitignore From Appearing In The List Of Untracked Files? How To Stop .gitignore From Appearing In The List Of Untracked Files?
How To Move Branch Pointer To Different Commit Without Checkout? How To Move Branch Pointer To Different Commit Without Checkout?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
23