Category: Git

  • git windows always show modified

    $ git status


    Changes not staged for commit:
    (use “git add …” to update what will be committed)
    (use “git restore …” to discard changes in working directory)
    modified: .cicd/update-svc-values.sh

    no changes added to commit (use “git add” and/or “git commit -a”)

    how to fix:

    git config core.fileMode false

  • git 根据条件计算中间 commit 数量

    https://stackoverflow.com/a/11657647/3672812

    在 feature 分支下

    git rev-list --count HEAD ^master
    
    13
    
  • git 一个commit 有多个 tag

    一个 commit 不小心打了多个 tag

    输出最新的 tag

    LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
    

    根据最新的 commit 显示多个 tag

    git show-ref --tags | grep $(git rev-parse v0.2.0)
    a359509551c1a85cdfbf7675d3f7f36a8577ee38 refs/tags/v0.2.0
    a359509551c1a85cdfbf7675d3f7f36a8577ee38 refs/tags/v0.3.0
    
  • git 查看具体一次 commit 改动的文件

    方法一:

    git --no-pager log -n 1 --name-only ${COMMIT_SHA} 
    

    方法二:

    git --no-pager show --stat=1000,800 ${COMMIT_SHA}
    
  • git-crypt

    gpg --list-secret-keys
    gpg --list-keys
    
    

    导出 secret key

    gpg --export-secret-keys YOUR_ID_HERE > private.key
    

    导入 secret key

    gpg --import private.key
    

    查看加密文件

    git-crypt status

    解密整个 repo

    git-crypt unlock
  • pycharm terminal git bash windows

    windows 自带的 terminal 太难用了,用 git bash

    https://stackoverflow.com/questions/20573213/embed-git-bash-in-pycharm-as-external-tool-and-work-with-it-in-pycharm-window-w

    git bash upgrade
    $ git version
    git version 2.24.0.windows.2

    $ git update-git-for-windows

    Or download from official site
    https://git-scm.com/downloads