Make new repo and push the existing code again to the new repo
git init doesn’t initialize if you already have a .git/ folder in your repository. So, for your case, do -
(1) rm -rf .git/
(2) git init
(3) git remote add origin https://repository.remote.url
(4) git commit -m “Commit message”
(5) git push -f origin master
Note that all git configs like remote repositories for this repository are cleared in step 1. So, you have to setup all remote repository URLs again.
Also, take care of the -f in step 5 : The remote already has some code base with n commits, and you’re trying to make all those changes into a single commit. So, force-pushing the changes to remote is necessary.
reference path is 'https://github.com/orgs/community/discussions/23135'
'형상관리 > git' 카테고리의 다른 글
02. Create new branch and push (0) | 2024.08.28 |
---|---|
01. git 사용하기 (0) | 2024.08.28 |
result command after using command by $git remote --help (2) | 2023.12.21 |
git [ERROR] - Could not read from remote repository. (0) | 2022.07.28 |
git pull [reset, pull] (0) | 2022.07.12 |