0

As discussed here we can get commit message of a given revision via command

$ git log --format=%B -n 1 $revNum

Though this command requires we are inside the git repo folder i.e. somewhere below folder containing .git folder. That requires us to pushd and popd to go in and out of the .git folder every time we want to call the command (from external working directory).

I'm looking for params of git log command that help to specify .git folder like that. Please share as you know the ones.

p.s.

My google found me this one though adding --git-dir=$myCode/.git --work-tree=$myCode not working for git log command.

1 Answer 1

3

I think you can use -C option for that. But keep in mind that you need to add the -C option before the git command you want to use (log, status, ...).

For example:

git -C ~/src/docker log

But the following will not work:

git log -C ~/src/docker

You can also use --git-dir, but you cannot use you shell capabilities of globbing in that case and you need to use the full path (no *, ~, etc.):

git --git-dir=/home/nam/src/docker/.git log
Sign up to request clarification or add additional context in comments.

1 Comment

Ah, the -C param of git command that works. I focus so much on git log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.