很难解释,但基本上我有一个已删除其本地.git
信息的克隆远程存储库。一些工作已经完成;但现在我需要将它整合回远程仓库;我该如何' init'使用远程git repo的本地项目?我知道我可以git init
但我不想丢失历史或提交等等。
答案 0 :(得分:0)
再次克隆项目,然后使用 cp 或 rsync 命令覆盖已修改内容的工作树中的所有项目文件。
为了防止本地更改与远程之间发生潜在冲突,在克隆远程之后,您应该创建一个新的本地分支并使用本地修改覆盖其工作树。然后,将此本地分支与跟踪远程的分支合并。
答案 1 :(得分:0)
Assuming that the SHA of the last commit you had checked out was 3
, do the following:
abc123
If you don't know the exact commit you were last on, this will work if you pick any commit that is before the actual commit you were last on; the further back you go, the more merge conflicts you will have. Don't pick a commit that happened after the the actual commit you were last on, as that will cause you to lose changes.