简体   繁体   中英

Git Branch only pulls Master Branch in GitHub Actions

I am working with GitHub actions and I am trying to get the last branch that was merged into master and use that branch. I am currently trying to use.

echo "::set-output name=branch::$(git branch --merged master | tail -1)"

I am using this in the action.yml. I am only getting master from this rather than the other branches that I merged in. Does anyone understand why this might be. I even ran a fetch before hand to make sure the right information was on the local machine. My assumption is that it is not getting closed branches once they are merged. Is this possible in any way?

Cheers,

The part I was missing was the ordering which is wrong because master pulls itself in and considers itself committed last. I fixed this by using.

git branch --sort=committerdate -rav --merged master | tail -2 | head -1

This gets the right order and the second item from the list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM