public:it:git

差别

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

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
public:it:git [2023/02/06 14:15] oakfirepublic:it:git [2024/05/27 09:30] (当前版本) – [二、GIT 与 SVN 的区别] oakfire
行 12: 行 12:
     * SVN 的分支是一个完整文件目录;而 git 只保持一份本地文件目录,切换分支直接改变该目录文件;      * SVN 的分支是一个完整文件目录;而 git 只保持一份本地文件目录,切换分支直接改变该目录文件; 
   * GIT 没有全局唯一版本号;SVN 有;   * GIT 没有全局唯一版本号;SVN 有;
-    * git 可以打 tag 来弥补;+    * git 可以打 tag 来弥补;但是 tag 只与 commit id对应,而 commit id 不能保证代码的唯一性(因为不同分支的同一 commit id 之前的提交历史可能不一样),所以要保证 tag 唯一性,可额外人为规定只有主分支打的tag是有效的。
  
 ===== 三、GIT 资料 ===== ===== 三、GIT 资料 =====
行 106: 行 106:
   * 删除远程仓库分支:<code bash>git push origin --delete branchname</code>   * 删除远程仓库分支:<code bash>git push origin --delete branchname</code>
   * 删除本地的远程分支追踪(比如在远程分支删除后本地''git branch -a''还有遗留remote分支)<code bash>git branch -r -d origin/your_branch_name</code>   * 删除本地的远程分支追踪(比如在远程分支删除后本地''git branch -a''还有遗留remote分支)<code bash>git branch -r -d origin/your_branch_name</code>
 +  * 同步本地的远程分支追踪<code bash>git remote prune origin</code>
   * 打tag最好用-a -m ,多一个obj,方便管理 <code bash>git tag -a tagname -m "message" [commit]</code>   * 打tag最好用-a -m ,多一个obj,方便管理 <code bash>git tag -a tagname -m "message" [commit]</code>
   * 删除远程仓库tag<code bash>   * 删除远程仓库tag<code bash>
行 124: 行 125:
   * 合并特定的单个commit,可使用指令 ''git cherry-pick''   * 合并特定的单个commit,可使用指令 ''git cherry-pick''
   * 凭证存储: [[https://git-scm.com/book/zh/v2/Git-%E5%B7%A5%E5%85%B7-%E5%87%AD%E8%AF%81%E5%AD%98%E5%82%A8|credential.helper]],    * 凭证存储: [[https://git-scm.com/book/zh/v2/Git-%E5%B7%A5%E5%85%B7-%E5%87%AD%E8%AF%81%E5%AD%98%E5%82%A8|credential.helper]], 
-    * :!:如果设为store模式,将在本地明文存储用户密码+    * 如果设为store模式,将在本地明文存储用户密码,节省下次输入:<code bash>git config credential.helper store</code> :!:这样会<wrap hi>明文</wrap>保存密码到 '' ~/.git-credentials''
   * 打印更多日志:<code bash>GIT_TRACE=2 GIT_CURL_VERBOSE=1 git clone <repo></code> 详见[[https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#Debugging|git 环境变量]]   * 打印更多日志:<code bash>GIT_TRACE=2 GIT_CURL_VERBOSE=1 git clone <repo></code> 详见[[https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#Debugging|git 环境变量]]
   * 提交空commit: <code bash>git commit --allow-empty -m "Empty"</code>   * 提交空commit: <code bash>git commit --allow-empty -m "Empty"</code>
   * 修改上一次commit的message: <code bash>git commit --amend -m "new msg" </code>   * 修改上一次commit的message: <code bash>git commit --amend -m "new msg" </code>
-  * 保存用户名和密码, 节省下次输入:<code bash>git config credential.helper store</code> <wrap hi>注意这样会明保存密码到</wrap> '' ~/.git-credentials''+  * 设置 vim 为默认编辑器:<code bash>git config --global core.editor "vim"</code> 
 +  * 删除某件的所有历史记录,[[https://blog.csdn.net/yxpandjay/article/details/111275665|参考]]: 
 +    * 查找大文件:'' git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5 | awk '{print$1}')" '' 
 +    * 从历史记录删除:'' 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> 
 ==== server: gitolite ==== ==== server: gitolite ====
   * [[http://gitolite.com/gitolite/index.html|gitolite docs]]   * [[http://gitolite.com/gitolite/index.html|gitolite docs]]
  • public/it/git.1675664102.txt.gz
  • 最后更改: 2023/02/06 14:15
  • oakfire