git实用命令总结
来源:互联网 发布:软件测评 编辑:程序博客网 时间:2024/05/17 05:13
从远程克隆仓库
git clone {gitaddress}
新建分支
git branch branchName
检出分支
git checkout branchName
把文件加到跟踪态
git add file
当前目录下所有文件加入
git add .
合并指定分支到当前分支
git merge fromBranchName
暂存
git stash
如果有部分文件不想commit,可以使用stash暂存
git stash –工作目录回到你上一次提交版本
git stash pop –将最后一次暂存的文件放回工作目录
git stash apply stash@{1} 就可以将你指定版本号为stash@{1}的工作取出来
与远程分支默认绑定,push与pull的时候不需要指定分支
git branch –set-upstream-to=origin/dev
如果不指定绑定的话,push与pull的时候需要
git push origin localBranch:remoteBranch
git pull
回滚提交文件到某一次版本
git reset 版本引用
取消pull操作
git reset –hard HEAD
检出远程分支到本地分支
git checkout -b localBranch origin/remoteBranch
更新分支信息到本地
git fetch
revert and reset
git revert 是撤销某次操作,此次操作之前的commit都会被保留
git reset 是撤销某次提交,但是此次之后的修改都会被退回到暂存区
具体一个例子,假设有三个commit, git st:
commit3: add test3.c
commit2: add test2.c
commit1: add test1.c
当执行git revert HEAD~1时, commit2被撤销了
git log可以看到:
commit1:add test1.c
commit3:add test3.c
git status 没有任何变化
如果换做执行git reset –soft(默认) HEAD~1后,运行git log
commit2: add test2.c
commit1: add test1.c
- git实用命令总结
- Git 实用命令总结
- git实用命令
- Git实用命令速记
- Git一些实用命令
- git实用命令集锦
- Git实用操作命令
- git实用命令--使用
- git 实用命令
- Git实用命令补充
- git 实用命令整理
- 实用的git命令
- Linux实用命令总结
- git命令实用小技巧
- git命令(非常实用)
- 一些实用的git命令
- git常用命令,git实用命令,linux的git命令,-----2
- [GIT] git应用 命令总结
- 圆周率
- 第六周项目六 复数模板类
- C Primer Plus 练习 9-2
- mysql5.6 datetime一些测试结果
- CSS3制作各种平滑过渡的动画效果
- git实用命令总结
- Android优酷播放器SDK——Eclipse工程迁移Android Studio遇到问题
- .xcassets资源问题
- MaterialUp - 寻找材料设计灵感必备的网站
- 《大规模web服务开发技术》阅读笔记
- FreeMarker教程
- P:浏览器IE对空白字符的处理
- ubuntu 14.04 使用git 和 github
- cocos2dx游戏只关卡开发