[英]Git repository - switch project local repo and push it to existing git repo
Lets say i have inited new repo onto my eclipse workspace project "Myproject". 可以说,我已经将新的回购协议初始化到我的Eclipse工作区项目“ Myproject”中。 I have created a user and a repository to bitbucket.org/myuser/MyRepoHoldingMyProject. 我已经为bitbucket.org/myuser/MyRepoHoldingMyProject创建了一个用户和一个存储库。 Now unfortunatelly i messed up "Myproject" and i created a new project "MySecond" . 现在不幸的是,我弄乱了“ Myproject”并创建了一个新项目“ MySecond”。 What is the best way to push "MySecond" to MyRepoHoldingMyProject, to overwrite its files. 将“ MySecond”推送到MyRepoHoldingMyProject覆盖其文件的最佳方法是什么。 Do i have to delete the repo and make a new one, and then init "MySecond" ? 我是否必须删除存储库并创建一个新存储库,然后再初始化“ MySecond”? Or will it work when i just repleace the content and name of the "Myproject" ? 或者当我只是补充“ Myproject”的内容和名称时,它将起作用吗?
It would be a good idea to rename your remote repo to other name eg MyRepoHoldingMyProject_backup
and create a new repo MyRepoHoldingMyProject
. 最好将远程MyRepoHoldingMyProject_backup
重命名为其他名称,例如MyRepoHoldingMyProject_backup
并创建一个新MyRepoHoldingMyProject
。 Doing so you will not lost commit history or may be some valuable code. 这样做不会丢失提交历史记录,也可能是一些有价值的代码。
After that just: 之后,只需:
git init
in MySecond
project root directory, if you have not done it yet 如果您尚未在MySecond
项目根目录中MySecond
git init
,
git git remote add origin link_to_new_repo
git add -A
check with git status
which files were added git add -A
以git status
检查git add -A
哪些文件
git commit -m 'Initial commit'
git pull
git push
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.