开发者

Recover from Messed up commit to wrong origin

开发者 https://www.devze.com 2023-03-12 11:47 出处:网络
I have an eclipse wor开发者_如何转开发kspace with directories for various projects:project1, project2 etc. So i created a project1.git in a dropbox folder. I work on my code in project1, my working di

I have an eclipse wor开发者_如何转开发kspace with directories for various projects:project1, project2 etc. So i created a project1.git in a dropbox folder. I work on my code in project1, my working directory. I have git remote added "project1.git" as origin. So, here is exactly the stupid thing i did.I created a new project, named project2, and without adding a new remote origin for project2, i did a stupid git commit and git push origin. so project1 is now corrupted. How exactly do i recover from this? I mean, i want project1.git to have the current contents of project1 directory. And a fresh project2 folder with a separate project2.git remote origin..


You could just revert the commit in project2 and push again,

git revert HEAD
git push

Don't forget to change origin afterwards :)

0

精彩评论

暂无评论...
验证码 换一张
取 消