1 | git log --all --decorate --oneline --graph |
|---|
效果如下:

目录初始化
1 | git init |
|---|
设置远程仓库地址
1 | git remote add -f origin <origin_url> |
|---|
启用sparse checkout模式,允许克隆子目录
1 | git config core.sparsecheckout true |
|---|
在 .git/info/sparse-checkout 文件中指定要拉取的文件夹或文件:
1 2 | ## 例如要拉取远程仓库public目录下的所有文件 echo "public/*" >> .git/info/sparse-checkout |
|---|
如果要拉取多个文件夹或文件,只需要在 .git/info/sparse-checkout 文件中添加多个路径即可
开始拉取
1 | git pull origin master |
|---|
设置
1 2 3 | git config --global user.name “user01” git config --global user.password "password" git config --global user.email "test@123.com" |
|---|
删除配置
1 2 3 | git config --global --unset user.name “user01” git config --global --unset user.password "password" git config --global --unset user.email "test@123.com" |
|---|
git push和pull的默认远程分支1 2 | git branch --set-upstream-to=origin/test test git pull |
|---|
git pull免密码执行命令
1 | git config --global credential.helper store |
|---|
命令执行后会在家目录生成一个.gitconfig,内容如下:
1 2 | [credential] helper = store |
|---|
这时再执行git pull,输入用户名、密码后,相关信息会保存到.git-credentials文件中,下次再次拉取就不用输入密码啦。.git-credentials文件内容结构如下:
1 | http://<USERNAME>:<PASSWORD>@gitlab.com |
|---|