如何撤消已提交的子模块命令
How to undo a committed submodule command
我克隆了一个存储库,并进行了一些本地更改。
然后我做了 git pull origin
以从源获取更新的更改。然后我执行 git push
推送到我克隆的存储库。然而,子模块没有被推送:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
typechange: third_party/aten (new commits)
modified: third_party/cub (new commits)
modified: third_party/eigen (new commits)
modified: third_party/gloo (new commits)
modified: third_party/nccl (new commits)
我不知道我可以使用 git submodule update
来更新它们。我添加了它们,提交并推送到我的克隆存储库。
这是错误的。我的克隆存储库落后于原始存储库。现在我有一个对源的拉取请求,并且包含该提交。
只是想知道是否有一种简单的方法可以撤消它。强制我的克隆存储库使用与源相同的版本。
非常感谢!
如果您在上次提交中仅提交了子模块更改,则撤消(硬重置)最后一次提交,然后强制推送到远程(克隆回购)
$ git reset --hard HEAD~1 # undo the last commit
$ git push -f
撤消子模块更改的替代方法:
"It is not the last commit that having this issue" (mentioned in comment)
仅将 submodule 文件夹检出到特定的 commit
或 remote branch
,其中未提交文件夹的更改。
$ git fetch
$ git checkout <remote>/<branch> -- <submodule-folder>
Or,
$ git log # copy the commit hash want to get back the submodule folder
$ git checkout <commit-hash> -- <submodule-folder>
"To force my cloned repository to use the same version as origin."
在这里,我猜 origin
= upstream
(从你克隆回购的地方)。因此,您可以从 upstream
中提取更改,然后推送到克隆的 repo 分支。
$ git remote add upstream <upstream repo url> # add a new remote with the original repo url
$ git pull upstream master # pull the upstream master branch changes into local branch
$ git push # update remote branch
现在,使用原始(上游)存储库更新克隆的存储库。
我克隆了一个存储库,并进行了一些本地更改。
然后我做了 git pull origin
以从源获取更新的更改。然后我执行 git push
推送到我克隆的存储库。然而,子模块没有被推送:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
typechange: third_party/aten (new commits)
modified: third_party/cub (new commits)
modified: third_party/eigen (new commits)
modified: third_party/gloo (new commits)
modified: third_party/nccl (new commits)
我不知道我可以使用 git submodule update
来更新它们。我添加了它们,提交并推送到我的克隆存储库。
这是错误的。我的克隆存储库落后于原始存储库。现在我有一个对源的拉取请求,并且包含该提交。
只是想知道是否有一种简单的方法可以撤消它。强制我的克隆存储库使用与源相同的版本。
非常感谢!
如果您在上次提交中仅提交了子模块更改,则撤消(硬重置)最后一次提交,然后强制推送到远程(克隆回购)
$ git reset --hard HEAD~1 # undo the last commit
$ git push -f
撤消子模块更改的替代方法:
"It is not the last commit that having this issue" (mentioned in comment)
仅将 submodule 文件夹检出到特定的 commit
或 remote branch
,其中未提交文件夹的更改。
$ git fetch
$ git checkout <remote>/<branch> -- <submodule-folder>
Or,
$ git log # copy the commit hash want to get back the submodule folder
$ git checkout <commit-hash> -- <submodule-folder>
"To force my cloned repository to use the same version as origin."
在这里,我猜 origin
= upstream
(从你克隆回购的地方)。因此,您可以从 upstream
中提取更改,然后推送到克隆的 repo 分支。
$ git remote add upstream <upstream repo url> # add a new remote with the original repo url
$ git pull upstream master # pull the upstream master branch changes into local branch
$ git push # update remote branch
现在,使用原始(上游)存储库更新克隆的存储库。