在Github上有一个空的私人存储库(我可以访问它),我将我的代码推送到其中。 现在所有者要求我清空存储库并将我的代码作为拉取请求发送。 有人能帮我清空存储库并将我的代码作为拉取请求发送吗? 提前感谢您的帮助。
在Github上有一个空的私人存储库(我可以访问它),我将我的代码推送到其中。 现在所有者要求我清空存储库并将我的代码作为拉取请求发送。 有人能帮我清空存储库并将我的代码作为拉取请求发送吗? 提前感谢您的帮助。
我相信我有一个相似的问题... “如何使用全新存储库发起拉取请求?”
为了做到这一点,我的想法是创建两个本地分支:
那么你的问题就是“对于空分支,如何覆盖现有代码”?好吧,你不能。只有在提交时才能拥有远程存储库。它不能真正为空。为了处理这个问题,只需创建一个带有初始化的单个提交。稍后,你会看到我使用 rebase 构建新添加的初始提交。
解决方案 - 这是我做的方式,假设两件事情:
命令说明:
git checkout -b new # assuming "new" is your latest code for pull request to an empty repo
git branch -D master
git checkout -b master # create a fresh master
touch emptyfile; git add .; git commit -m "init commit"
git push origin master
git checkout new
git rebase master # If you're confused by what rebase does, try doing your own little research on it
git push origin new
现在你可以从new分支合并到master分支了!你只需要在此之后删除emptyfile即可。
--allow-empty
参数,可以跳过 touch emptyfile; git add.
步骤:git commit --allow-empty -m "init commit"
。 - nyi