跳到主要内容

git使用技巧汇总

· 阅读需 1 分钟
Danny He
Developer in ChengDu,China

别名:更方便的使用命令

配置git使用别名

git config --global alias.st status
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.br branch
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

也可直接编辑Git的全局配置文件.gitconfig

[alias]
st = status
co = checkout
ci = commit
br = branch
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

即可使用

git co -b dev
提示

这里是以创建新的本地分支dev为例演示checkout的别名co

Git lfs

大文件容易超时

加大活跃时间

git config lfs.activitytimeout 60

显示文件下载进度

GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/Qwen/Qwen2.5-1.5B-Instruct.git
cd Qwen2.5-1.5B-Instruct
git lfs pull