| 两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 |
| public:it:git [2025/07/18 13:59] – [Git 原理] oakfire | public:it:git [2026/07/10 11:11] (当前版本) – [Tips] oakfire |
|---|
| * [[http://wp.joak.org/?p=62 | Git 博文备查]] | * [[http://wp.joak.org/?p=62 | Git 博文备查]] |
| * [[https://github.com/commitizen/cz-cli | Commitizen:Git 提交信息优化]] | * [[https://github.com/commitizen/cz-cli | Commitizen:Git 提交信息优化]] |
| | * [[https://conventional-branch.github.io/zh/| 分支命名规范]] |
| * [[http://pcottle.github.io/learnGitBranching/|Learning git branching]] | * [[http://pcottle.github.io/learnGitBranching/|Learning git branching]] |
| * [[https://nvie.com/posts/a-successful-git-branching-model/|git flow]],[[https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow|gitflow-workflow]] | * [[https://nvie.com/posts/a-successful-git-branching-model/|git flow]],[[https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow|gitflow-workflow]] |
| ==== Ignore ==== | ==== Ignore ==== |
| * [[http://git-scm.com/docs/gitignore|gitignore]] | * [[http://git-scm.com/docs/gitignore|gitignore]] |
| | * 白名单的写法为:<code> |
| | * |
| | |
| | !.gitignore |
| | |
| | # whitelist `src` directories and their children, regardless of place |
| | !src/ |
| | !src/**/ |
| | !src/**/*.h |
| | !src/**/*.cpp |
| | |
| | !/docs/ |
| | !/docs/*.md |
| | </code> |
| ==== Submodule ==== | ==== Submodule ==== |
| * 参考[[http://josephjiang.com/entry.php?id=342|Git Submodule 的認識與正確使用!]] | * 参考[[http://josephjiang.com/entry.php?id=342|Git Submodule 的認識與正確使用!]] |
| git am | git am |
| </code> | </code> |
| | ==== 接手旧项目时的git操作 ==== |
| | [[https://piechowski.io/post/git-commands-before-reading-code/|git-commands-before-reading-code]] |
| | <markdown> |
| | 1. 哪个文件改动最频繁: |
| | `git log --format=format: --name-only --since="1 year ago" | sort | uniq -c | sort -nr | head -20` |
| | 2. 谁维护的项目: |
| | `git shortlog -sn --no-merges` |
| | 3. 哪些文件发生BUG多: |
| | `git log -i -E --grep="fix|bug|broken" --name-only --format='' | sort | uniq -c | sort -nr | head -20` |
| | 4. 这个项目是在加速发展还是正在走向衰亡?(按月提交数排行) |
| | `git log --format='%ad' --date=format:'%Y-%m' | sort | uniq -c` |
| | 5. 项目团队需要多频繁地“救火”? |
| | `git log --oneline --since="1 year ago" | grep -iE 'revert|hotfix|emergency|rollback'` |
| | </markdown> |
| | |
| ==== Tips ==== | ==== Tips ==== |
| * 查看暂存区(git add 的内容)的修改:''git diff --staged'' 或 ''git diff --cached'' | * 查看暂存区(git add 的内容)的修改:''git diff --staged'' 或 ''git diff --cached'' |
| * 显示差异时忽略行尾空格差异: <code bash>git diff --ignore-space-at-eol</code> | * 显示差异时忽略行尾空格差异: <code bash>git diff --ignore-space-at-eol</code> |
| * git log 中文显示为尖括号码,修正方式:''export LESSCHARSET=utf-8'' | * git log 中文显示为尖括号码,修正方式:''export LESSCHARSET=utf-8'' |
| | * 如果''git status'' 里的中文被转译成了八进制显示,改为中文显示:<code bash>git config --global core.quotepath false</code>,前提得确保终端支持utf-8中文显示 |
| |
| ==== server: gitolite ==== | ==== server: gitolite ==== |
| 但对使用者来说, 命令的正交性不强这一点, 就造成了使用者需要记住大量单独的命令. | 但对使用者来说, 命令的正交性不强这一点, 就造成了使用者需要记住大量单独的命令. |
| 考虑找个或弄个简化版的本地版本控制系统, 或者做个git的命令包装. | 考虑找个或弄个简化版的本地版本控制系统, 或者做个git的命令包装. |
| 这篇文章不错:https://www.highflux.io/blog/what-makes-git-hard-to-use | 这篇文章不错:https://www.highflux.io/blog/what-makes-git-hard-to-use . |
| 这个可借鉴:https://github.com/jj-vcs/jj | 这个可借鉴:https://github.com/jj-vcs/jj . |
| </WRAP> | </WRAP> |
| |