Skip to content

Instantly share code, notes, and snippets.

@huangboju
Last active October 26, 2023 09:18
Show Gist options
  • Save huangboju/04a7413a0e67d189108d4ba9b2443a1e to your computer and use it in GitHub Desktop.
Save huangboju/04a7413a0e67d189108d4ba9b2443a1e to your computer and use it in GitHub Desktop.

删除远端最后三个commit

  • git reset --hard HEAD~3
  • git push --force
  • git ls-remote

拉分支,推到远端

  • git checkout -b branch_name
  • git push -u origin branch_name

查询一段时间某个人的commit

  • git log --pretty=format:"%ad - %an: %s" --after="2023-09-25" --until="2023-10-18" --author="张三
  • git log --oneline 5433d1c728bed805b5bdb75a4daa47217d392d8a..bb6cce5d845a29fe88410a5118a969af5f3683fd --author=bul

git 配置

git config user.name huangboju
git config user.email "xiaoju.foxmail@gmail.com" 

ssh

ssh-keygen -t ed25519 -C 邮箱
cat ~/.ssh/id_ed25519.pub

copy以上公钥

清理本地分支

git fetch -p ; git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
import re

def read_txt():
    with open("git_del.txt", mode='r') as f:
        for line in f.readlines():
            m = re.search("git branch(.+?)'.", line, re.M)
            if m is not None:
                cmd = m.group()
                print(cmd.replace("'.", ""))

read_txt()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment