8

I have a meta project with a number of submodules in it. I would like to run the following lines inside a foreach loop of some kind.

cd $subDirectory "\n\nModule $subDirextory" >> log git log --pretty=format:"%h%x09%an%x09%ad%x09%s" origin/${Branch}..HEAD >> log cd .. 

The idea is to get a log from the last branch point up to HEAD for each submodule in the meta repo. How can I go about doing this?

1 Answer 1

8

The command you are looking for is probably:

git submodule foreach 'git log --pretty=format:"%h%x09%an%x09%ad%x09%s" @{u}..HEAD' 

git submodule foreach will loop over all the submodules, cwd into them and run the given command. It will also output the name of each of the submodules before doing that.

@{u} refers to the remote tracking branch of the currently checked out branch.

The part I’m not sure about is quoting in PowerShell. The command given above will work in bash. You will have to make sure yourself that the part within ' is passed to git without modifications.

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

1 Comment

d= (◕‿↼ ) This works! but may not for git reset, see: stackoverflow.com/a/27415757/8740349

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.