开发老人笔记:Git 常用命令清单
2023-02-18 16:27:01 时间
摘要:git是目前世界上最先进的分布式版本控制系统。
多人协作
- master:此分支用来发布稳定的代码,合并一般是由管理员合并
- dev:此分支用于团队开发,团队成员向此分支提交代码
- bug:此分支用于修复紧急bug,修复完成后一般删除
MASTER 分支
当dev完成一个版本的测试后,合并到master
git merge dev
DEV 分支
在本地创建dev分支,需要 git push origin dev 同步到远程
git merge dev 不需要进行git add 等操作,它自动完成了
Git默认会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息,一般情况下应该使用 git merge --no-ff -m "merge with no-ff" dev
其他用户加入DEV
- 现在本地创建,报错的原因是未和远程代码关联
- 合并冲突
- 提交到dev
BUG 分支
当我们在自己的分支开发时,突然接到项目经理的反馈的一个bug,但是此时我们工作区有缓存数据,只需要使用 git stash
相关命令
创建并切换分支
- git checkout -b dev
切换分支
- git check dev
查看当前分支
- git branch
删除分支
- git branch -d dev
更新项目组文件夹内容
- git reset --hard
--no-ff git branch -d '' 后,在git log 可以看到信息
- git merge --no-ff -m "merge with no-ff" dev
git pull
- git pull = git fetch + git merge origin/master
git config
- git config --global user.name "username"
- git config --global user.email "email"
git branch -D <name>
- 丢弃分支
git rm -r --cached
- gitignore考虑不全面,发现有不该提交的文件已经提交后,用该命令
问题记录
- error: cannot open .git/FETCH_HEAD: Permission denied
# 未授予权限,在post-receive中产生了一个关联操作,故报错
chown -R git:git /data/wwwroot/deploy/tools/
- Failed to connect to http://github.com port 443: Timed out
# 公司内网需设置 # 设置ss git config --global http.proxy 'socks5://127.0.0.1:1080' git config --global https.proxy 'socks5://127.0.0.1:1080' # 设置代理 git config --global http.proxy http://127.0.0.1:1080 git config --global https.proxy https://127.0.0.1:1080 # 查看是否成功 git config --get http.proxy 172.17.18.80:8080 # 取消代理 git config --global --unset http.proxy git config --global --unset https.proxy
本文分享自华为云社区《Git 常用命令及多用户相关操作》,原文作者:CodeStack。
相关文章
- 教你配置windows上的windbg,linux上的lldb,打入clr内部这一篇就够了
- 使用mongodb作为Quartz.Net下的JobStore实现底层的持久化机制
- mongodb之使用explain和hint性能分析和优化
- mongodb 3.x 之实用新功能窥看[2] ——使用$lookup做多表关联处理
- mongodb 3.x 之实用新功能窥看[1] ——使用TTLIndex做Cache处理
- 双十一来了,别让你的mongodb宕机了
- 分享几个你可能不知道的交互式Git 命令
- 实践GoF的23的设计模式:SOLID原则(下)
- 实践GoF的23种设计模式:SOLID原则(上)
- k8s源码Client-go中Reflector解析
- HTTP流量神器Goreplay核心源码详解
- 手把手带你基于嵌入式Linux移植samba服务
- 8天学通MongoDB——第八天 驱动实践
- 8天学通MongoDB——第七天 运维技术
- 8天学通MongoDB——第六天 分片技术
- 8天学通MongoDB——第五天 主从复制
- 8天学通MongoDB——第四天 索引操作
- 8天学通MongoDB——第三天 细说高级操作
- 8天学通MongoDB——第二天 细说增删查改
- 8天学通MongoDB——第一天 基础入门