git fetch 更新远程仓库到本地
来源:互联网 发布:淘宝客网站源码破解版 编辑:程序博客网 时间:2024/04/29 19:15
Git中从远程的分支获取最新的版本到本地方式如下,
如何更新下载到代码到本地,请参阅ice的博客基于Github参与eoe的开源项目指南
方式一
1. 查看远程仓库
123456
$ git remote -veoecn https://github.com/eoecn/android-app.git (fetch)eoecn https://github.com/eoecn/android-app.git (push)origin https://github.com/com360/android-app.git (fetch)origin https://github.com/com360/android-app.git (push)su@SUCHANGLI /e/eoe_client/android-app (master)
从上面的结果可以看出,远程仓库有两个,一个是eoecn,一个是origin
2 ,从远程获取最新版本到本地
1234
$ git fetch origin masterFrom https://github.com/com360/android-app * branch master -> FETCH_HEADsu@SUCHANGLI /e/eoe_client/android-app (master)
$ git fetch origin master 这句的意思是:从远程的origin仓库的master分支下载代码到本地的origin master
3. 比较本地的仓库和远程参考的区别
12
$ git log -p master.. origin/mastersu@SUCHANGLI /e/eoe_client/android-app (master)
因为我的本地仓库和远程仓库代码相同所以没有其他任何信息
4. 把远程下载下来的代码合并到本地仓库,远程的和本地的合并
123
$ git merge origin/masterAlready up-to-date.su@SUCHANGLI /e/eoe_client/android-app (master)
我的本地参考代码和远程代码相同,所以是Already up-to-date
以上的方式有点不好理解,大家可以使用下面的方式,并且很安全
方式二
1.查看远程分支,和上面的第一步相同
2. 从远程获取最新版本到本地
1234
$ git fetch origin master:tempFrom https://github.com/com360/android-app * [new branch] master -> tempsu@SUCHANGLI /e/eoe_client/android-app (master)
git fetch origin master:temp 这句命令的意思是:从远程的origin仓库的master分支下载到本地并新建一个分支temp
- 比较本地的仓库和远程参考的区别
12
$ git diff tempsu@SUCHANGLI /e/eoe_client/android-app (master)
命令的意思是:比较master分支和temp分支的不同
由于我的没有区别就没有显示其他信息
4. 合并temp分支到master分支
123
$ git merge tempAlready up-to-date.su@SUCHANGLI /e/eoe_client/android-app (master)
由于没有区别,所以显示Already up-to-date.
合并的时候可能会出现冲突,有时间了再把如何处理冲突写一篇博客补充上。
5.如果不想要temp分支了,可以删除此分支
123
$ git branch -d tempDeleted branch temp (was d6d48cc).su@SUCHANGLI /e/eoe_client/android-app (master)
如果该分支没有合并到主分支会报错,可以用以下命令强制删除git branch -D <分支名>
总结:方式二更好理解,更安全,对于pull也可以更新代码到本地,相当于fetch+merge,多人写作的话不够安全。
如有错误请指正
声明:eoe文章著作权属于作者,受法律保护,转载时请务必以超链接形式附带如下信息
原文作者: com360
原文地址: http://my.eoe.cn/com360/archive/3533.html
- git fetch 更新远程仓库到本地
- Git更新远程仓库代码到本地 git fetch
- Git更新远程仓库代码到本地 git fetch
- Git更新远程仓库代码到本地 git fetch
- Git更新远程仓库代码到本地 git fetch
- Git更新远程仓库代码到本地 git fetch
- Git更新远程仓库代码到本地方法 git fetch
- 【Git学习笔记】git fetch取回远程库的更新到本地仓库中
- git fetch 的简单用法:更新远程代码到本地仓库
- git fetch 的简单用法:更新远程代码到本地仓库
- git fetch 的简单用法:更新远程代码到本地仓库
- git fetch 的简单用法:更新远程代码到本地仓库
- git fetch 的简单用法:更新远程代码到本地仓库
- 【git fetch】的简单用法:更新远程代码到本地仓库
- git fetch 的简单用法:更新远程代码到本地仓库
- git fetch 的简单用法:更新远程代码到本地仓库
- [CodeVersion--GIT]将远程仓库分支fetch到本地
- Git更新远程仓库代码到本地
- 基于贪心算法的几类区间覆盖问题:
- 插值法
- 类型转换: 自动类型转换:数值范围小的转到数值范围大 强制类型转换:数值范围大的转到数值范围小 浮点类型的数据想其他类型转化时需要强制类型转换,同时可能发生精度丢失 当强制把数值范围大的转化为数值范
- sql中什么时候用内连接查询,什么时候用外连接查询?用起来好像一样啊!
- 字符集
- git fetch 更新远程仓库到本地
- gdb 打印变量时出现 "No symbol "i" in current context"
- Leetcode 215. Kth Largest Element in an Array
- Android 代码混淆 webview混淆
- eclipse设置自动生成注释
- ubuntu防火墙ufw
- zookeeper搭建
- java中求两个时间差
- ios 即时聊天轻松搞定