GIT confusion with restKit

2019-09-11 14:28发布

So i am learning to ever so slowly use git to get me the latest update of RestKit as the old version has retain cycles...fair enough HOWEVER, when i pull using the gitHub Client it does not give me the AFNetworking files, which i was then told use the command

git submodule update --init --recursive

which i do, problem is that i noticed that after running that i run

git submodule status

It has taken me off the master branch and put the HEAD back in thus reverting me to old stuff. and hence back to leaks and stuff.

So i thought maybe i could install using cocoapods or perhaps put a submodule within the restkit submodule for AFNetworking...all did not seem to work and now i have followed this guide How do I remove a submodule? up until the last step as i dont know what committing will do? i hope it does not commit the fact that i deleted everything onto the restkit site? i am so confused, initially all i wanted to do was switch the current branch submodule i have to the master.

Assistance would be much appreciated.

EDIT: Okay as to answer what Commit does, commit only affects your copy of the repository and will in no way affect the remote "main" repository everyone else gets their code from, so in essence i was able to commit it, then run a brand new submodule from the branch i wanted, But the question still remains Is there a way to switch the branch you pull your data from when using the update with --recursive?

1条回答
Juvenile、少年°
2楼-- · 2019-09-11 14:53

Simply go in th e RestKit directory and type:

git pull origin master

(if you use the master branch of course)

Also, if you need to update all your submodules, just go to the root of your project, and type:

git submodule foreach git pull

git submodule update is confusing, here what it really does:

When you invoke git submodule update it looks in the parent repository for a SHA for each submodule, goes into those submodules, and checks out the corresponding SHAs. As would be the case if you checked out a SHA in a regular repository, this puts the submodule into a detached HEAD state.

EDIT

To switch branch of a submodule simply, let say 'development', simply do in the submodule git checkout development and then you should be able to do git pull origin development

查看更多
登录 后发表回答