Git常用命令整理(慢慢更新)

一般常用命令

git init //生成.git目录
git add . //把当前目录里的文件加入到暂存区
git add README //更新README文件
git commit -m ‘上传’ //从暂存区提交到仓库
git remote add origin 远程仓库地址 //添加远程仓库
git branch --set-upstream-to=origin/ master //本地仓库和远程仓库关联,git pull时就会有提示
git status //会有信息显示:Your branch is up-to-date with ‘origin/master’.不过一般远程仓库会和现有仓库合并不了,单纯的git pull会提示fatal: refusing to merge unrelated histories

git pull --rebase origin master //看来以rebase变基的方式可以合并啊
git push //提交到远程仓库
git push -u origin master

大文件

上传大文件报错remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.

git lfs install //安装LFS
git lfs track ".a" //".a"是上传的大文件路径
git add .gitattributes //添加,相当于add .
git add 大文件 //添加大文件到本地缓存区
再commit>>push

其他

git config --global core.autocrlf false //关闭自动换行
git config --global core.safecrlf true

git tag # 列出当前仓库的所有标签
git tag -l ‘v0.1.*’ # 搜索符合当前模式的标签
git tag v0.2.1-light # 创建轻量标签
git tag -a v0.2.1 -m ‘0.2.1版本’ # 创建附注标签
git checkout [tagname] # 切换到标签
git show v0.2.1 # 查看标签版本信息
git tag -d v0.2.1 # 删除标签
git tag -a v0.2.1 9fbc3d0 # 补打标签
git push origin v0.1.2 # 将v0.1.2标签提交到git服务器
git push origin --tags # 将本地所有标签一次性提交到git服务器
git tag # 查看当前分支下的标签

变更项目地址

git remote set-url origin git@192.168.6.70:res_dev_group/test.git
git remote -v

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Gufra_Yin

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值