I know a commit with subject should be in git, but do not know which branch it belong to. how can I find the commit has specific subject?
Below command only run on current branch:
git log --oneline |grep subject
CodePudding user response:
I think that you can grep the log directly with:
git log --grep="subject"
CodePudding user response:
:/^[^\n]*subject
names the most recent commit with that in its subject reachable from any ref. git branch --contains ':/^[^\n]*subject'
shows all the branches containing that commit. For script usage git for-each-ref --format='%(refname:short)' refs/heads --contains ':/^[^\n]*subject'
won't gratuitously add markup.
If you don't want to confine the search to just the subject line you can lose the ^[^\n]*
anchor.