public:it:git

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
public:it:git [2024/07/19 10:12] – [Installation] oakfirepublic:it:git [2026/07/10 11:11] (当前版本) – [Tips] oakfire
行 32: 行 32:
   * [[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]]
 +  * [[https://jvns.ca/blog/2024/01/26/inside-git/|Inside .git]], 介绍 .git 文件夹内容
 +  * [[https://blog.gitbutler.com/how-git-core-devs-configure-git/| git config 的一些设置技巧]]
  
 ==== 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 的認識與正確使用!]]
行 94: 行 111:
 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''
行 137: 行 169:
     * 从历史记录删除:'' git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch "your/big.file"' HEAD --all  ''     * 从历史记录删除:'' git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch "your/big.file"' HEAD --all  ''
   * 显示差异时忽略行尾空格差异: <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 status'' 里的中文被转译成了八进制显示,改为中文显示:<code bash>git config --global core.quotepath false</code>,前提得确保终端支持utf-8中文显示
  
 ==== server: gitolite ==== ==== server: gitolite ====
行 148: 行 182:
 但对使用者来说, 命令的正交性不强这一点, 就造成了使用者需要记住大量单独的命令. 但对使用者来说, 命令的正交性不强这一点, 就造成了使用者需要记住大量单独的命令.
 考虑找个或弄个简化版的本地版本控制系统, 或者做个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 .
 </WRAP> </WRAP>
  
  • public/it/git.1721355140.txt.gz
  • 最后更改: 2024/07/19 10:12
  • oakfire