常用命令與技巧(git/svn/vim等)
阿新 • • 發佈:2022-05-28
1、git
1.1、推程式碼
git checkout 檔名 ==============回退某檔案修改
git add 需要新增的檔案路徑
git commit -m "xxxxxx" ============生成conmit資訊
git push origin HEAD:refs/for/master ==========將程式碼推送到分支master最新節點上
1.2、去除git add新增的檔案
去除git add修改 git rm --cached “檔案路徑”,不刪除物理檔案,僅將該檔案從快取中刪除; git reset 也可以 git rm --f “檔案路徑”,不僅將該檔案從快取中刪除,還會將物理檔案刪除
1.3、去掉每行結尾的^M
windows和linux行結尾差異導致
%s/^M//g 或者 %s/\r//g 然後esc退出 :wq儲存退出 git diff 去掉匹配換行差異 git config --global core.whitespace cr-at-eol
1.4、git push 失敗
push 失敗:顯示 error Missing tree
git push 後增加 --no-thin https://opendev.org/opendev/git-review/commit/39cd763d5d3ae310b00e54f6fc24eba993ed57f5 這是gerrit的一個bug,丟失了git tree ,gerrit在推送是預設是採用thin,將發生的包降低到最低,忽略本地和遠端文件公共部分。
1.5、git status 只顯示被跟蹤檔案
git status -uno