Git&Github相关

Zhengpeng Liao Lv3

删除GitHub远程库中的文件:

1
2
3
git rm -r --cached <delete-dir/file>
git commit -m "delete <sth>"
git push origin

使用裸git库作为服务器与本地机的中转站

  • 首先在中转服务器上建立新裸的git repo
    1
    2
    3
    cd <repo_path>
    mkdir <repo_name>.git
    git init --bare <repo_name>.git
  • 本地机的repo,添加对应的远程引用
    1
    2
    3
    4
    # 类似GitHub
    git remote add <ref_name> <user_name>@<server_ip>:<repo_path>/<repo_name>.git
    git add -A; git commit -m ".."; # 如果需要提交。。。
    git push <ref_name> # 将当前已经提交的工作区内容提交至中转站
  • 远程服务器上,clone中转站的repo
    1
    git clone <user_name>@<server_ip>:<repo_path>/<repo_name>.git

查看文件提交历史以及修改历史

使用 git log -p 即可。

给git repo打tag

标记版本号以及备注:

1
git tag -a v1.0 -m "release the 1.0 version"

查看已有的tag:

1
git tag 

提交打上tag的包:

1
git push origin --tags

注意,上面这一操作可以在github的release界面看到已经打包的源代码。

  • 标题: Git&Github相关
  • 作者: Zhengpeng Liao
  • 创建于 : 2021-05-06 20:23:14
  • 更新于 : 2026-10-24 17:55:32
  • 链接: https://wswslzp.github.io/2021/05/06/Git-Github相关/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。