前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >git 使用技巧

git 使用技巧

作者头像
吴易娃
发布2024-07-23 10:49:36
890
发布2024-07-23 10:49:36
举报
文章被收录于专栏:易娃的杂货铺

git log美化输出

1

git log --all --decorate --oneline --graph

效果如下:

git 拉取指定目录或文件

目录初始化

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

git 设置全局用户名、密码、邮箱

设置

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 pushpull的默认远程分支

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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-11-30,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • git log美化输出
  • git 拉取指定目录或文件
  • git 设置全局用户名、密码、邮箱
  • 设置​git push​和​pull​的默认远程分支
  • 设置git pull​免密码
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档