您现在的位置是: 首页> 其他>git常用命令 所属分类:其他
git常用命令
初柒先生
2019-09-05 11:45
【git】
205人已围观
简介git代码版本管理常用命令
1、查看提交记录:git log 查看所有的提交记录
查看所有提交记录
git log
查看提交记录,每条用一行显示
git log --oneline
2、查看提交详情
查看最新提交详情
git show
查看指定提交详情
git show commitId
查看指定提交的文件详情
git show commitId fileName
3、查看远程版本
git remote -v
4、拉取远程代码到本地:pull和fetch
(1)使用git pull 从远程拉取最新版本到本地自动执行合并命令”git merge”(默认合并到master)
git pull origin master
注:拉取远程“origin”仓库(默认仓库)的”master“分支(默认分支),不推荐使用。
(2)使用git fetch 从远程拉取最新版本到本地并新建一个分支
git fetch origin master:temp
注:在本地新建“temp分支”,我们可以使用“git diff temp”命令查看temp分支与本地原分支的不同,然后决定是否合并。
5、查看temp分支与本地原有分支的不同
git diff temp
6、将temp分支和本地的master分支合并
git merge temp
7、temp分支删除
git branch -d temp
8、放弃本地修改,再拉取远程代码
git reset --hard
git pull
用于解决如下错误:
error: Your local changes to the following files would be overwritten by merge:
xxx/xxx/xxx.java
Please, commit your changes or stash them before you can merge.
Aborting
很赞哦! (1)
初柒先生
2019-09-05 11:45
【git】
205人已围观
上一篇:已经没有了
相关文章
文章评论
猜你喜欢
