git命令记录

找回数据 两种办法:

1
2
git reflog show
git reset --hard HEAD@{1} # 从上一步找到希望回退的位置

或者

1
2
git fsck --lost-found
cd .git/lost-found/

用 git show hash 查看悬空对象的内容

用 git merge hash 或者 git rebase hash 来恢复到当前分支里

合并分支时创建合并commit

1
git config branch.master.mergeoptions "--no-ff"

删除远程分支

1
git push --delete origin branch

删除已经合并的分支 参考

删除已合并的本地分支

1
2
3
git branch --merged \
    | grep -E "^\\s+(patch|feat|refactor|test|misc)" \
    | xargs -I{} git branch -d {}

删除已合并的远程分支

1
2
3
4
git branch -r --merged \
    | grep -E "^\\s+origin/(patch|feat|refactor|test|misc)" \
    | sed 's/origin\///' \
    | xargs -I{} echo git push --delete origin {}找回数据

两种办法:

1
2
git reflog show
git reset --hard HEAD@{1} # 从上一步找到希望回退的位置

或者

1
2
git fsck --lost-found
cd .git/lost-found/

用 git show hash 查看悬空对象的内容

用 git merge hash 或者 git rebase hash 来恢复到当前分支里

合并分支时创建合并commit

1
git config branch.master.mergeoptions "--no-ff"

删除远程分支

1
git push --delete origin branch

删除已经合并的分支 参考

删除已合并的本地分支

1
2
3
git branch --merged \
    | grep -E "^\\s+(patch|feat|refactor|test|misc)" \
    | xargs -I{} git branch -d {}

删除已合并的远程分支

1
2
3
4
5

git branch -r --merged \
    | grep -E "^\\s+origin/(patch|feat|refactor|test|misc)" \
    | sed 's/origin\///' \
    | xargs -I{} echo git push --delete origin {}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
❯ git add ./*
fatal: LF would be replaced by CRLF in Dockerfile

flink-sql-submit  [🌱 flink17.1][ 📝6 ][📦 v1.1][☕ v17.0.7]
❯ git config core.autocrlf true            

flink-sql-submit  [🌱 flink17.1][ 📝6 ][📦 v1.1][☕ v17.0.7]
❯ git add ./*                  
fatal: LF would be replaced by CRLF in Dockerfile

flink-sql-submit  [🌱 flink17.1][ 📝6 ][📦 v1.1][☕ v17.0.7]
❯ git add --renormalize .

flink-sql-submit  [🌱 flink17.1][ 🗃️ 6 ][ 📦 v1.1][☕ v17.0.7]
❯ git commit -m "updatefix"    
Licensed under CC BY-NC-SA 4.0
最后更新于 Jan 06, 2025 05:52 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up