Ignore new commits for git submodule

后端 未结 6 545
执笔经年
执笔经年 2020-11-30 20:50

Background

Using Git 1.8.1.1 on Linux. The repository looks as follows:

master
  book

The submodule was created as follows:

6条回答
  •  时光取名叫无心
    2020-11-30 21:32

    Nevik Rehnel answer is certainly the correct one for what you are asking: I did not want to have a submodule, how the heck do I get out of that situation?!.

    Only, if your master project requires the book submodule, it is a nice gesture to keep it as such because that way other users who checkout your project can then enjoy not having any special git command to run (well... there are some special commands to use submodules, but it still simpler to manage, overall, I think.)

    In your case you make changes in the book repository and at some point you commit those changes. This means you have new commits in that submodule, which have a new SHA1 reference.

    What you need to do in the master directory is commit those changes in the master repository.

    cd /path/to/master
    git commit . -m "Update 'book' in master"
    

    This will updated the SHA1 reference in master to the newest version available in the book repository. As a result this commit allows others to checkout all of the master & book repositories at the tip.

    So in effect you end up with one more commit whenever you make changes to a submodule. It is semi-transparent if you also make changes to some files in the master repository since you'd commit both at the same time.

提交回复
热议问题