使用 GitHub README profile 展示更多信息

时间:2022-07-22
本文章向大家介绍使用 GitHub README profile 展示更多信息,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

近期,GitHub 上线了 GitHub README profile 的功能,于是我的首页多了一些 GitHub 的代码信息。

创建 README profile 非常简单:

  1. 创建一个仓库,仓库的名字与你 GitHub 的 username 保持一致,比如我的是 ShixiangWang(这里大小写无所谓,GitHub 并不区分)。创建时如果选择初始化一个 README 就不需要进行下面一步了。
  1. 创建一个 README.md 文件。

在这里你所填入的所有信息都会被及时渲染到 GitHub 首页啦,支持常规的 Markdown 语法。

当然有人不仅仅满足于一般的文字了,有前端大神就写出了一些有用的代码用于展示,在 https://github.com/abhisheknaiidu/awesome-github-profile-readme[1] 可以找到很多内容。

我使用的是 https://github.com/anuraghazra/github-readme-stats[2]

只需要在文档中加入一句代码:

[![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra "![Anurag's github stats")](https://github.com/anuraghazra/github-readme-stats)

就能实现汇总的效果。

试试吧!

最后提供一段小代码,将 origin 为 Gitee 的仓库设置为 GitHub 同名仓库,这跟自动镜像 GitHub 仓库文章有关。

#!/usr/bin/env bash
# Author: Shixiang Wang 
# LICENSE MIT@2020

echo "This program reset the origin repository from gitee to github."

remote=$(git status && echo $(git remote -v | grep fetch | sed -E 's/.*(http[s][^ ]*).*/1/') || echo "Not a git repo")

if [[ $remote == "Not a git repo" ]]; then
    echo "!! Not a git repo, exit..."
    exit 1
fi

remote=$(echo $remote | sed -E 's/.*(http[s][^ ]*)$/1/')
remote=$(echo $remote | sed -E 's/gitee/github/')

git remote remove origin
git remote add origin $remote

echo "Done."

Reference

[1]

https://github.com/abhisheknaiidu/awesome-github-profile-readme: https://github.com/abhisheknaiidu/awesome-github-profile-readme

[2]

https://github.com/anuraghazra/github-readme-stats: https://github.com/anuraghazra/github-readme-stats