Git如何强制拉取一个远程分支到本地分支(转载)
有时候,我们在使用git pull指令想把一个远程分支拉取到本地分支的时候,老是会拉取失败,这一般是因为某种原因,本地分支和远程分支的内容差异无法被git成功识别出来,所以git pull指令什么都不会拉取下来或拉取失败。下面这个帖子的方法可以解决这个问题,强制拉取一个远程分支的所有内容来覆盖本地分支。
问:
The scenario is following:
- A team member is modifying the templates for a website we are working on
- They are adding some images to the images directory (but forgets to add them under source control)
- They are sending the images by mail, later, to me
- I'm adding the images under the source control and pushing them to GitHub together with other changes
- They cannot pull updates from GitHub because Git doesn't want to overwrite their files.
This is the error I'm getting:
error: Untracked working tree file 'public/images/icon.gif' would be overwritten by merge
How do I force Git to overwrite them? The person is a designer - usually I resolve all the conflicts by hand, so the server has the most recent version that they just needs to update on their computer.
答:
Try this:
git reset --hard HEAD
git pull
It should do what you want.
Git如何强制拉取一个远程分支到本地分支(转载)的更多相关文章
- 【转】【Mac + Git】之Git pull 强制拉取并覆盖本地代码
Git pull 强制拉取并覆盖本地代码 git fetch --all git reset --hard origin/master git pull 参考文章: <Git pull 强制拉取 ...
- Git pull 强制拉取并覆盖本地代码
git fetch --all git reset --hard origin/master git pull
- 版本控制git之三-多人协作 变基 推送 拉取 删除远程分支
版本控制git之三-多人协作 wangfeng7399已关注0人评论350人阅读2019-02-20 21:33:08 如果你想获得一份已经存在了的 Git 仓库的拷贝,比如说,你想为某个开源 ...
- 21.拉取&删除远程分支
拉取 当 git fetch 命令从服务器上抓取本地没有的数据时,它并不会修改工作目录中的内容. 它只会获取数据然后让你自己合并. 然而,有一个命令叫作 git pull 在大多数情况下它的含义是一个 ...
- git常用操作 配置用户信息、拉取项目、提交代码、分支操作、版本回退...
git常用操作 配置用户信息.拉取项目.提交代码.分支操作.版本回退... /********git 配置用户信息************/ git config --global user.name ...
- git 本地仓库和远程仓库及本地分支和远程分支
从远程git仓库签出代码: $ git clone git://aaa.com/git_project.git (远程git服务器项目所在地址) 当你需要克隆远程项目到本地时,默认会把项目保存在名 ...
- 使用git提交和拉取gitee的代码
使用git提交和拉取gitee的代码 1. 安装Git(自行摸索) 2. 在gitee新建仓库 名称和路径自己写 这两个二选一足矣 默认分支master就行 复制这个链接,待会要用 3. 新建项目目录 ...
- git 删除远程分支和本地分支
删除远程分支和本地分支 https://www.cnblogs.com/luosongchao/p/3408365.html 将远程git仓库里的指定分支拉取到本地(本地不存在的分支) https:/ ...
- 解决 MySQL 比如我要拉取一个消息表中用户id为1的前10条最新数据
我们都知道,各种主流的社交应用或者阅读应用,基本都有列表类视图,并且都有滑到底部加载更多这一功能, 对应后端就是分页拉取数据.好处不言而喻,一般来说,这些数据项都是按时间倒序排列的,用户只关心最新的动 ...
随机推荐
- 不得不知Git远程操作详解
Git是目前最流行的版本管理系统,学会Git几乎成了开发者的必备技能. Git有很多优势,其中之一就是远程操作非常简便.本文详细介绍5个Git命令,它们的概念和用法,理解了这些内容,你就会完全掌握Gi ...
- 动态设置表格[GridView]在编辑时 只读。
找到GridView的CellEditorInitalize事件. protected void agv_main_CellEditorInitialize(object sender, ASPxGr ...
- [field:description /]标签如何限制字数?|DedeCms
[field:description /]标签如何限制字数? [field:description function='cn_substr(@me,80)'/]dede 里的所有标记都支持这样使用函数 ...
- postman+newman+jenkins环境部署
postman+newman+jenkins 环境部署 2017年4月27日 14:33 阅读 11 新浪博客 1.postman: http://itfish.net/article/59864.h ...
- CodeForces - 344B Simple Molecules (模拟题)
CodeForces - 344B id=46665" style="color:blue; text-decoration:none">Simple Molecu ...
- Win7如何自定义鼠标右键菜单 添加在此处打开CMD窗口
将下面文件保存为"右键添加在此处打开CMD窗口.reg"双击导入运行即可 Windows Registry Editor Version 5.00 [HKEY_CLASSES_RO ...
- LeetCode 206 Reverse Linked List(反转链表)(Linked List)(四步将递归改写成迭代)(*)
翻译 反转一个单链表. 原文 Reverse a singly linked list. 分析 我在草纸上以1,2,3,4为例.将这个链表的转换过程先用描绘了出来(当然了,自己画的肯定不如博客上面精致 ...
- js:Razor视图下服务器代码给Javascript变量赋值
namespace Razor.Controllers { public class JSController : Controller { public ActionResult Index() { ...
- Codeforces Hello2015第一题Cursed Query
英文题面: De Prezer loves movies and series. He has watched the Troy for like 100 times and also he is a ...
- iOS中UDP的使用
// // ViewController.m // UDPDemo // // Created by qianfeng01 on 15-8-13. // Copyright (c) 2015年 ...