Git的常用操作
2016-03-23 16:52
387 查看
1 概念
概念 | 意义 |
---|---|
HEAD | 当前版本 |
HEAD^ | 上一个版本 |
HEAD~N | 往上第 N 个版本 |
origin | 远程仓库的默认名称 |
master | 默认主干分支名 |
2 指令
指令 | 意义 |
---|---|
git init | 创建仓库 |
git clone | 克隆远程仓库 |
git status | 当前状态 |
git diff | 查看更改 |
git checkout file | 撤销工作区 file 文件的修改 |
git reset HEAD file | 将暂存区文件 file 的修改撤销到工作区 |
git add | 将文件修改添加到暂存区 |
git commit | 提交修改(将暂存区提交到当前分支) |
git push | 将本地分支提交到远程分支(设置了upstream) |
git push origin master | 将本地的 master 分支推送到远程 origin 分支 |
git pull | 从远程分支获取更改 |
git reset --hard commit_id | 版本回退,将HEAD指向 commit_id |
git log | 查看提交记录 |
git log --graph | 查看分支合并图 |
git reflog | 查看用户的每一次命令记录 |
git merge - -no-ff branch_name | 合并 branch_name 分支到当前分支(不使用Fast Forward模式) |
git branch | 查看分支 |
git branch branch_name | 创建分支 branch_name |
git checkout branch_name | 切换到分支 branch_name |
git branch -d branch_name | 删除分支 branch_name |
git remote | 查看远程仓库信息 |
git checkout -b local_branch_name origin/remote_branch_name | 克隆远程分支 remote_branch_name 到本地分支 local_branch_name |
git branch --set-upstream local_branch_name origin/remote_branch_name | 设置本地分支 local_branch_name 的upstream为远程分支remote_branch_name |
git tag tag_name commit_id | 在 commit_id 上设置标签 tag_name ,如果省略 commit_id 则在最后的commit上打标签 |
git push origin --tags | 将tag更新到远程仓库 |
git config --global | 查看全局设置 |
git config --global core.autocrlf false | 全局设置提交时自动将结束符 CRLF转换成 LF |
相关文章推荐
- JMeter学习(四)参数化
- 检测身份证号码是否合法
- imp导入数据的时候报错:ORA-01658: 无法为表空间 MAXDATA 中的段创建 INITIAL 区
- MySQL性能优化的最佳20+条经验
- Ext 要讲json拼成Ext的datagrid格式的字符串
- jsp相关-jsp2.0表达式
- hdoj4540 威威猫系列故事——打地鼠
- CentOS下phpMyAdmin安装
- 集成Dubbo服务(Spring)
- C#旅途之 窗口化的a+b
- 利用rsync服务定时同步tomcat日志
- 备份一个数据库中每个表的100条数据的存储过程
- MySQL实现大整数相加的udf
- Centos7 下配置mysql5.6主从复制实例(一主两从)
- 神奇的$scope
- RabbitMQ队列,Redis\Memcached缓存
- 代码添加自动布局,告别绝对坐标
- 【BZOJ 3527】 [Zjoi2014]力|FFT
- 理解android:targetSdkVersion
- intellij 13新建javaweb项目并用tomcat 7启动