分类
git

git 查看具体一次 commit 改动的文件

方法一:

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

方法二:

git --no-pager show --stat=1000,800 ${COMMIT_SHA}
分类
git

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
分类
git

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

clean_merged 清理已经合并的 git 分支

alias clean_merged='git checkout master && git branch --merged | grep -v master | xargs git branch -D'
分类
git

git 分支重命名 rename branch

本地 branch 重命名 foo => bar

1. 本地重命名,切到分支 foo

git branch -m bar

或者直接重命名

git branch -m foo bar

2. 如果分支已经在远端,查看远端 origin

git remote show origin

  Remote branches:
    foo    tracked
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local refs configured for 'git push':
    foo    pushes to foo    (up to date)
    master pushes to master (up to date)

这就需要把本地分支 bar push 上去,把 foo 分支删掉

git push origin :foo bar
 - [deleted]         foo
 * [new branch]      bar -> bar

最后在本地的 bar 分支下把 upstream 设置好

git push origin -u bar
Branch bar set up to track remote branch bar from origin.

查看远端 origin

git remote show origin

  Remote branches:
    bar    tracked
    master tracked
  Local branches configured for 'git pull':
    bar    merges with remote bar
    master merges with remote master
  Local refs configured for 'git push':
    bar    pushes to bar    (up to date)
    master pushes to master (up to date)

删除远端分支

 git push origin :feature/upgrade-gke                                                                                                                    master * ] 12:02 PM
To github.com:xxx/yyy.git
 - [deleted]         feature/upgrade-gke