git使用记录一:配置账户信息
配置的级别
- git config --gloabal 针对当前用户下所有的项目 设置
- git config --local 针对当前工作区的项目来进行设置
- git config --system 针对当前系统下所有的账户进行设置
配置账户信息
- git config --global user.name 'soaeon' 设置昵称
- git config --global user.email 'soaeon@163.com' 设置邮箱
- git config --global http.postBuffer 524288000 设置文件最大上传容量500M
- ssh-keygen -t rsa -C 'soaeon@163.com' 生成key :C:\Users\soaeon.ssh 将公钥复制到gitlab/github
清除错误的属性
- git config --global --unset key(属性名字,比如: http..postbuffer)
克隆项目/初始化仓库
如果项目已经存在, 那么 git clone 克隆项目吧
git clone http://xxx.xxx.com/asd/asxc.git
如果项目不存在, 跳转到项目目录下, 初始化
git init
git 三个区的解释
工作区: 本地的工作目录
暂存区: commit 之后是将工作区的内容提交到 暂存区域
远程区: remote origin 这个才是真正的提交到git的远程仓库了
最简单的提交
查看文件的状态
git status
将文件加入
git add index.html
提交
git commit -m 'commit index.html'
暂存区的文件需要修改名字
git mv 原文件名 新文件名字
git mv index.html inde.html
修改完可以直接提交到暂存区
git commit -m 'move index.html to inde.html'
通过 git log 查看最近的演变
查看git 提交的历史
git log
以简洁的方式查看git的log
git log --oneline
查看最近两次的提交
git log -n2
以图形化的方式简单的查看提交的历史
git log --oneline --graph
关于分支的使用
查看所有的分支
git branch
创建分支testing
git branch testing
切换到分支testing
git checkout testing
查看每一个分支最后一次的提交
git branch -v
创建并且切换到分支demo
git checkout -b demo
删除一个分支
git branch -d hotfix
强制删除一个分支
git branch -D hotfix
查看本地分支和远程分支
git branch -va
将hotfix分支合并到master分支
- 切换到master分支
- 执行命令 合并到master git merge hotfix
如果两个分支修改了同一个文件呢
还原场景:
- hotfix 分支修改 hot.html文件
- hotfix 提交 git add hot.html , git commit -m 'upadte'
- 切换到master分支 git checkout master
- 修改hot.html 文件 vi hot.html
- 提交修改 git add hot.html , git commit -m 'master update hot.html'
- 执行合并 git merge hotfix
这个时候 有冲突的提示:
解决方法1: git mergetool
解决方法2:使用 git status 查看状态, 然后使用vi hot.html 编辑文件
最新文章
- mongo日志切割脚本
- C#操作.csv文件Demo
- (转)Python:self
- 动态代理双剑客--JDK Proxy与CGLIB
- lightoj Again Array Queries
- How to initialize a static const map in c++?
- eclipse debug 多线程
- C++随机崩溃捕捉处理
- react基础学习
- sortable的基本属性
- ORACLESQL语句的优化
- Jmeter(三十七)循环控制器+交替控制器+事务控制器 完美实现接口字段参数化校验
- 页面传递的都是string ; 每个标签要有name的原因是为了取值 因为传递给后台是键值对的形式
- logical_backup: expdp/impdp
- WEB框架本质和第一个Django实例
- Pygame安装教程
- 论文笔记之:Deep Attributes Driven Multi-Camera Person Re-identification
- Java安全技术
- Linux Socket - 基本socket链接
- lintcode-394-硬币排成线
热门文章
- Thrift报错:Error: Thrift compiler: Failed to translate files. Error: Cannot run program thrift error=2
- Learning OSG programing---osgwindows
- 记录pgsql数据库表设计date和time字段的处理
- 微信小程序中new Date()转换时间时间格式时IOS不兼容的问题
- Ubuntu下安装chrome浏览器步骤
- 三、IDS4建立authorization server
- Ansible--04 ansible 流程控制
- Nginx四层负载均衡
- Codeforces 669E cdq分治
- 五、Redis五种类型 - 字符串类型