git命令

--设置提交者信息

git config --global user.name XXXXX
git config --global user.email XXXXX@gmail.com
# 仅设置当前仓库的提交人信息
git config user.name XXXXX
git config user.email XXXXX@gmail.com

--设置查看当前仓库配置

git config --list

--创建YYY目录作为新的git仓库,并下载远程YYY仓库的所有分支(当前分支为仓库设置的默认分支)

git clone https://github.com/XXXXX/YYY.git
# 不再推荐使用ssh协议
git clone git@github.com:XXXXX/YYY.git

--更新当前仓库

git pull

--把已有目录连接到YYY仓库的master分支

# 把当前目录转换为一个git仓库
git init
# git clone时也是用origin作为远程仓库的默认别名
git remote add origin https://github.com/XXXXX/YYY.git
# 拉取远程代码
git pull origin <分支名>
# 本地和远程分支,不同名时的拉取方法
git pull origin <远程分支名>:<本地分支名>

--提交当前目录的文件

git add .
git commit -m 'first commit'
# 推送
git push origin <分支名>
# 本地和远程分支如果硬要使用不同名称
git push origin <本地分支名>:<远程分支名>

--创建develop分支

# git reset --hard <历史提交的hash码>
git checkout -b develop
# 本地远程分支都叫develop时,只需写一个
git push origin develop

--切换到develop分支

git checkout develop

--合并develop分支到master

git checkout master
git merge develop
git push origin master

--删除develop分支

git push origin --delete develop
git checkout master
git branch -D develop

--引入外部模块

git submodule add -b branch1 https://<外部地址>.git <本地目录>

--设置代理 

# 限定仓库域名是https://github.com时,使用http代理
git config --global http."https://github.com".proxy http://localhost:1080
# 取消代理配置
git config --global --unset https."https://github.com".proxy

 --设置账户名 

github不能用账户密码进行push了,需要使用accessToken代替账户密码

# 限定仓库域名是https://github.com时,使用账户xxx
git config --global credential."https://github.com".username xxx

  --保存账户信息 

# 同域名的仓库只需输入一次密码
git config --global credential.helper store
# 清理已存储的账户密码
rm -f ~/.git-credentials

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值