Git-subrepo: How to work out if you have changes to any subrepo that haven't been pushed back?

Created on 17 Oct 2017  路  5Comments  路  Source: ingydotnet/git-subrepo

if you have a lot of subrepos, how do you find the ones that got changed as part of your main project and need to be integrated back to their respective repos?

Question

Most helpful comment

@grimmySwe Yes. But I did that. See: https://gist.github.com/anonymous/b772c6806a58a6a54f011cf8a2df427d#file-x-bash-L4

The status command shows a line like thist (if there is a branch):

Worktree: /Users/ingy/src/git-subrepo/.git/tmp/subrepo/ext/test-more-bash  24a6cce [subrepo/ext/test-more-bash]

If we show that line, we can at least say how many commits ahead or behind it it.

All 5 comments

Hi @keithn,
There is unfortunately no easy way to determine this right now. You can look at #274 for an explanation of some steps that can be performed.

There is an -A option for push but then you will push all your subrepos and that might not be the desired behavior.

Try something like this Bash command:

for subrepo in $(git subrepo status --quiet); do echo "New local commits for subrepo $subrepo:"; git subrepo branch --fetch --force --quiet $subrepo; commit=$(git subrepo status $subrepo | grep Worktree: | awk '{print $3}'); (set -x; git log --oneline FETCH_HEAD..$commit); done

Reformatted here: https://gist.github.com/b772c6806a58a6a54f011cf8a2df427d

@grimmySwe we could add something to status to tell how commits ahead or behind a subrepo branch is.

@ingydotnet But don't you need to fetch and actually perform the subrepo branch to be able to find out the actual status?

@grimmySwe Yes. But I did that. See: https://gist.github.com/anonymous/b772c6806a58a6a54f011cf8a2df427d#file-x-bash-L4

The status command shows a line like thist (if there is a branch):

Worktree: /Users/ingy/src/git-subrepo/.git/tmp/subrepo/ext/test-more-bash  24a6cce [subrepo/ext/test-more-bash]

If we show that line, we can at least say how many commits ahead or behind it it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kohlhase picture kohlhase  路  3Comments

chrisdtaylor picture chrisdtaylor  路  6Comments

carlokok picture carlokok  路  3Comments

danielbsig picture danielbsig  路  7Comments

phest picture phest  路  6Comments