Linux下Git用户配置-记录用户名和密码

git配置个人用户信息

%% 配置用户名
git config --global user.name wangjing
%% 配置用户邮箱
git config --global user.email xxxx@qq.com

%% 配置记住用户验证信息
git config --global credential.helper store

%% 查看相关配置信息
git config --list

保存账号信息

%% 新建或打开文件 ~/.git-credentials
vim ~/.git-credentials

%% 配置格式如下:
%% DOMAIN.XXX  服务器地址例如:github.com | bitbucket.org | 其他服务器地址
%% GITUSER     用户名
%% GITPASSWORD 用户密码
https://GITUSER:GITPASSWORD@DOMAIN.XXX

%% 示例
%% 账号1  username: wangjing, password:wang123, server:https://bitbucket.org
%% 账号2  username: wangjing, password:wang456, server: http://39.39.39.39:3000
%% 注意 : 网址中特殊字符需转义
https://wangjing:wang123@bitbucket.org
http://wangjing:wang456@39.39.39.39%3a3000

git常用命令-分支

%% 查看本地分支
git branch

%% 查看全部分支(本地和远程)
git branch -a

%% 创建新分支BranchName
git branch BranchName

%% 切换到新分支BranchName
git checkout BranchName

%% 创建并切换到新分支BranchName
git branch -b BranchName

%% 切换到远程分支BranchName
git branch -b BranchName origin/BranchName

git常用命令-标签

%% 推送标签
git push origin 标签名

%% 推送全部标签
git push origin --tags

%% 列出标签
git tag

%% 删除本地标签
git tag -d 标签名

%% 删除远程标签
git push origin :refs/tags/标签名

%% 更改远程地址 
git remote set-url origin 仓库地址
%% 示例
git remote set-url origin http://39.39.39.39:3000/gittab/qx.git

git 代理设置

%% 全局代理
git config --global http.proxy 127.0.0.1:1087

%% 局部代理 在仓库内设置
git config --local http.proxy 127.0.0.1:1087

%% 查询全局代理
git config --global http.proxy

%% 查询局部代理
git config --local http.proxy

%% 取消全局代理
git config --global --unset http.proxy

%% 取消局部代理
git config --local --unset http.proxy

git使用镜像

大陆欲访问github而不可得,可临时通过镜像方式访问

%% 镜像1
%% 地址: github.com.cnpmjs.org
%% 用法: github.com.cnpmjs.org 代替 github.com即可
%% 新仓库示例
git clone https://github.com/xxxxx/xxxxxxx.git              %% github地址
git clone https://github.com.cnpmjs.org/xxxxx/xxxxxxx.git   %% 镜像地址


%% 镜像2
%% 地址:https://gitclone.com/
%% 用法:
git clone https://github.com/xxxxx/xxxxxxx.git                %% github地址
git clone https://gitclone.com/github.com/xxxxx/xxxxxxx.git   %% 镜像地址

本地设置镜像
git config --global url.https://gitclone.com/github.com/.insteadOf https://github.com/
本地取消镜像
git config --global --unset url.https://gitclone.com/github.com/.insteadOf https://github.com/

posted @   敬code  阅读(3793)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
点击右上角即可分享
微信分享提示