[✔️]git使用遇到的问题汇总

105 阅读2分钟

开启掘金成长之旅!这是我参与「掘金日新计划 · 2 月更文挑战」的第 3 天,点击查看活动详情

git 删除超过限制的大文件

git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch 文件路径" --prune-empty --tag-name-filter cat -- --all

替换上边的文件路径,注意分号,git会依次从所有commit中删除这个提交历史,完成之后,正常push就行了

vscode中gith关联远程分支

image.png

有时想基于remote base branch创建一个local new branch,并且希望remote自动同步新建一个remote new branch,在vscode中新建的分支会自动和remote base branch关联,预期是希望和remote new branch关联,vscode中并没有提供类似这样的操作,这时需要用到以下的git命令:

git branch -u remote/branch
git branch --set-upstream-to remote/branch

取消和远程分支关联

git branch --unset-upstream
  • 小tips 11:59:26.166: [111] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false checkout -b 3.2 ffmpeg/release/3.2^0 -- Switched to a new branch '3.2'

git action: github upload to release failed

  - name: Upload to release
    uses: xresloader/upload-to-github-release@v1
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    with:
      file: "src/libluajit.a"
      tag: false
      draft: false 

action里面上传文件时提示失败

File found to upload: /home/runner/work/luajit/luajit/src/libluajit.a
Try to get release by tag v2.1-86bd17b2 from tidys/luajit
Try to get release by tag v2.1-86bd17b2 from tidys/luajit : Not Found
Try to get draft release v2.1-86bd17b2 from tidys/luajit
Try to create release v2.1-86bd17b2 for tidys/luajit
Try to create release v2.1-86bd17b2 for tidys/luajit failed: Resource not accessible by integration

HttpError: Resource not accessible by integration
    at /home/runner/work/_actions/xresloader/upload-to-github-release/v1/lib/index.js:5167:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async run (/home/runner/work/_actions/xresloader/upload-to-github-release/v1/lib/index.js:20945:13)
Error: Try to create release v2.1-86bd17b2 for tidys/luajit failed: Resource not accessible by integration
HttpError: Resource not accessible by integration
    at /home/runner/work/_actions/xresloader/upload-to-github-release/v1/lib/index.js:5167:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async run (/home/runner/work/_actions/xresloader/upload-to-github-release/v1/lib/index.js:20945:13)
Start uploading asset: /home/runner/work/luajit/luajit/src/libluajit.a(size: 672610) ...
Upload asset: libluajit.a success

解决办法

  • 方法1:在仓库的Settings/Actions/General设置读写权限

image.png

  • 方法2:在action里面配置权限: permissions: write-all