0

I have read this documentation and didn't find answer for subject question.

My remote repository consists 3rd party submodules, those submodules changed and changes should be pushed into the my repository. As well I need to fetch new data from submodules.

Does GIT provide something for that ?

1 Answer 1

1

Your repo don't contain any submodule's code, it only store a pointer to some commit in your submodule

So, if you want to take in modifications from 3rd party submodules, you should $ cd /path/to/submodule/in/your/work/tree # enter your submodule directory $ git fetch origin # update $ git checkout origin/master # take in the modifications $ cd /path/to/your/work/tree $ git add /path/to/submodule/in/your/work/tree # add your modification for submodule pointer $ git commit -m "update xxx module to x.x.x.x" # commit

HOPE I CAN HELP YOU!

Sign up to request clarification or add additional context in comments.

6 Comments

It works, but how to fetch data from submodule origin after checkout (step 3) ?
@Dmitry after you git fetch origin in submodule, you already fetched remote repo updates to your local repo, so after step 2, "fetching data from submodule origin" has already been done. if you want to change master in submodule, you can get checkout master; git reset --hard origin/master in submodule directory, but be careful, Any changes to tracked files(of cause, in submodule) in the working tree are discarded, see here: kernel.org/pub/software/scm/git/docs/git-reset.html
This approach seems not working, because I can't commit changes nor clone repository. git clone url; git submodule update --init; And then: Cloning into 'test/src/github.com/guelfey/go.dbus'... remote: Reusing existing pack: 951, done. remote: Total 951 (delta 0), reused 0 (delta 0) Receiving objects: 100% (951/951), 314.59 KiB | 253 KiB/s, done. Resolving deltas: 100% (583/583), done. fatal: reference is not a tree: 562e287d99da12094e555597aba99b93a3ad5cce Unable to checkout '562e287d99da12094e555597aba99b93a3ad5cce' in submodule path 'test/src/github.com/guelfey/go.dbus'
Then I can make git checkout origin/master; inside module and get source tree in 'detached HEAD' state. But after git add; git commit; git push; on other computer I have same error message and no changed data. Git worked in client/server mode between two devs.
Unable to checkout 'xxx' mostly means you didn't push commit to your submodule repo. Suppose the url of 3rd party library(named B) repo is http://not/on/your/sever/B.git, your repo url is http://this/is/your/repo/server/A.git, you fetch submodule B from http://not/on/your/sever/B.git and then push to http:/this/is/your/repo/server/B.git, add submodule B to A git submodule add http://this/is/your/repo/server/B.git path/to/B/directory. when http://not/on/your/server/B.git updated, you should first commit those updates to your http://this/is/your/repo/server/B.git
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.