我在Bitbucket中有一个分支,现在我想在单个git
命令(远程分支)中找到最后一次提交的详细信息(该分支的最后一次提交用户名)。
我试过这个命令,但上面写着Not a git branch
。
git loghttps://userName:password@bitbucket.org/panchalajay/master.git-b branchname——单分支
最佳答案
如果不克隆repo,只有git ls-remote
会联系远程repo以获取数据(即分支名称、sha1和标记)。git ls-remote
不会带回任何其他信息,如作者身份。
为此,你可能会have to use像BitBucket API那样commit/revision的。
这将带回您需要的有关特定提交的所有信息。
所以:
使用git ls remote获取远程分支sha1和bitbucket api
或者只使用bitbucket api调用来查询远程repo。(例如refs/branches以获取相同的远程分支名称和sha1)
有了已经克隆的存储库,myold answer(这是this gist的基础)就足够了。
您可以添加筛选器以仅打印特定分支的数据。
制作一个名为git infob的bash脚本(没有扩展,甚至可以在windows上使用),其中:
#!/bin/bash
bname=$1
branches=$(git branch -r | grep -v HEAD)
for branch in ${branches}; do
branch_name=$(echo -n $branch | sed -e "s/origin\///g")
# echo ii ${branch_name} ${bname}
if [ "${bname}" == "${branch_name}" ]; then
git log -1 --format="%ai %ar by %an" $branch
fi
done
将该脚本放在
$PATH
/%PATH%
中的任何位置,然后调用git infob master
。