سؤال

My project is already set and working. Some of the files are from an external project. Now, I want to use git to manage the changes of the external file from upstream.

I did the following:

rm <external files>              # <= should use "git rm"
git commit -m "prepare submodule"

git submodule add <...remote...> extLibs
cd extLibs
git pull master
<make changes>
git commit -m"make external project work with my project"

cd .. # back to upper level project

At this point, I found I have to commit changes in my main repo again for the files I have already committed in the submodule. I don't even know if it is the correct behavior. Can I change it so I don't need to commit twice?

هل كانت مفيدة؟

المحلول

The only change you should see in your main repo is the gitlink (special entry 160000) referencing your git submodule folder should have changed (different SHA1).
You can add and commit that one change safely.

If you see more, that means your git rm didn't work as expected. (git rm -r extLibs/ should have done the job)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top