我可以在单个子模块中返回上一次提交吗?

时间:2018-12-02 19:35:08

标签: git git-submodules

我希望将我的应用程序设置为某些服务,但全部都放在一个存储库中。所以我想为每个服务添加一个子模块(目前我只有两个)。所以我的项目层次结构是:

- root
|--rootDoc.txt
|--.git
|
|---- sub1
    |--sub1.txt
    |--.git
|---- sub2
    |--sub2.txt
    |--.git

现在,我进行了以下更改:

  • 更改sub1.txt
  • 提交sub1子模块
  • 将主推为主
  • 更改sub2.txt
  • 提交sub2子模块
  • 将主推为主

现在,我想将sub1-子模块返回到上一次更改之前的状态,但将sub2保持在当前状态。如果子模块无法做到这一点,那么是否还有其他解决方案,还是我需要使用两个完全不同的存储库?

编辑: 我尝试过的:

c:\dev\root\sub1>git log
commit a172db9a5f11738383d28e082db2c22d3f2d3e75 (HEAD -> master, origin/master, origin/HEAD)
Author: %me%
Date:   Sun Dec 2 20:24:59 2018 +0100

    updated sub2

commit 0becb718a4db9c73b03fa65e332f20c7715463cb
Author: %me%
Date:   Sun Dec 2 20:23:40 2018 +0100

    sub1 actual now

commit 85d68703bff1af2b95a7ee8d7926d7fd700b1da4
Author: %me%
Date:   Sun Dec 2 20:10:50 2018 +0100

    Added submodules

commit b3b67de3e54f1db7e56d516af2baaf50541f7ca2
Author: %me%
Date:   Sun Dec 2 20:05:44 2018 +0100

    initial commit

c:\dev\root\sub1>git checkout 85d68703bff1af2b95a7ee8d7926d7fd700b1da4
Note: checking out '85d68703bff1af2b95a7ee8d7926d7fd700b1da4'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 85d6870 Added submodules

此签出后,尽管我从sub2目录(另一个子模块所在的位置)签出,但我的sub1也被更改了。

0 个答案:

没有答案