我怎样才能从Github(企业版)提交我本地没有的提交? [英] How can I pull down a commit from Github (Enterprise) that I don't have locally?
问题描述
我意外地在错误的repo上打了一个 push --force
(太多的termminals打开),有效地将master分支重新设置回早期的commit。
查看我的构建系统,我可以看到用于指向XYZ的提交,但是我没有在本地提交该提交,因为我最近没有执行提取或提取操作。回购在Github中,我可以在Github中浏览以查看提交,所以我知道它在那里。
如何取消提交以便重置 master
回到正确的提交而不必打扰推动该更改的开发人员?
- 浏览到
< h2>笔记
这篇文章对我研究这个很有帮助。它基本上声明,除非您有一个包含孤立提交的本地存储库,否则您将被卡住。我的方法允许您添加一个分支,以便提交不再孤立。
I accidentally did a
push --force
on the wrong repo (too many termminals open), effectively resetting the master branch back to an earlier commit.Looking at my build system I can see that the commit used to point to XYZ, however I don't have that commit locally as I hadn't done a pull or fetch recently. The repo is in Github, and I can navigate in Github to view the commit, so I know it is there.
How can I pull down the commit so I can reset
master
back to the right commit without having to bother the dev who pushed that change?解决方案You can create a branch from an orphaned commit in the Github GUI by doing the following:
- Browse to https://github.com/yourOrg/yourRepo/tree/commitHash
- Click on the branch dropdown
- Type in the new branch name and hit Enter
Now that you have a branch, you can use your Git client to check it out as normal.
Notes
This post was helpful as I researched this. It basically states that you are stuck unless you have a local repository containing the orphaned commits. My approach allows you to add a branch so the commit is no longer orphaned.
这篇关于我怎样才能从Github(企业版)提交我本地没有的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!