how to force git to overwritten local files
最佳解决方法
重要提示:如果您有任何本地更改,将会丢失。无论是否有--hard选项,任何未被推送的本地提交都将丢失。
如果您有任何未被Git跟踪的文件(例如上传的用户内容),这些文件将不会受到影响。
下面是正确的方法:
git fetch --all
然后,你有两个选择:
git reset --hard origin/master
或者如果你在其他分支上:
git reset --hard origin/<branch_name>
说明:
git fetch从远程下载最新的,而不尝试合并或rebase任何东西。
然后git reset将主分支重置为您刚刚获取的内容。 --hard选项更改工作树中的所有文件以匹配origin/master中的文件
[*]:值得注意的是,在重置之前可以通过从master创建一个分支来维护当前的本地提交:
git checkout master
git branch new-branch-to-save-current-commits
git fetch --all
git reset --hard origin/master
在此之后,所有旧的提交都将保存在new-branch-to-save-current-commits中。然而,没有提交的更改(即使staged)将会丢失。确保存储和提交任何你需要的东西。
转载: https://vimsky.com/article/3679.html
how to force git to overwritten local files的更多相关文章
- Force git to overwrite local files on pull 使用pull强制覆盖本地文件 转载自:http://snowdream.blog.51cto.com/3027865/1102441
How do I force an overwrite of local files on a git pull? I think this is the right way: $ git fetch ...
- Github Clone to local files
cd to you local files address key the word: git clone -0 github https://github.com/xxxxxxxxx Done... ...
- [Practical Git] Remove unnecessary git tracking with .gitignore files
Most projects have automatically generated files or folders from the operating system, applications, ...
- npm run eject 命令后出现This git repository has untracked files or uncommitted changes错误
npm run eject 暴露隐藏的文件,不可逆 结果出现下面的问题 This git repository has untracked files or uncommitted changes: ...
- git之删除untrack files
退回版本 git reset --hard commit_id //不保留未提交的修改 git reset --soft commit_id //默认方式,保留未提交的修改 撤除本地没有提交的修改 g ...
- git error: Your local changes to the following files would be overwritten by merge:xxxxxx ,Please commit your changes or stash them before you merge.的phpstorm解决办法
git报错 error: Your local changes to the following files would be overwritten by merge: .idea/encoding ...
- git:error: Your local changes to the following files would be overwritten by merge:
最近用git在服务器.github.本地更新代码的时候,因为频繁修改偶尔出现这个错误 覆盖本地的代码: git stash git pull git stash pop 保留对服务器上的修改: git ...
- Git操作删除 untracked files
最近使用git 管理项目的时候,编译过程中出现了很多中间文件,今天发现使用 git clean 命令可以很方便进行清除: # 删除 untracked files git clean -f # 连 u ...
- Git CMD - rm: Remove files from the working tree and from the index
命令格式 git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file>… 命令参 ...
随机推荐
- 关于阮一峰老师es6(第三版)中管道机制代码的理解浅析
最近正在学习阮一峰老师的es6(第三版)教材,在学到第七章<函数的扩展>中的箭头函数嵌套时,文中提到了一个关于“管道机制”的示例,文中源代码如下: //es6(第三版)教材中的管道机制源代 ...
- JS-实现横向手风琴
横向手风琴-- 鼠标悬浮某一张图片,图片显示,其他图片影藏. <div class="content"> <ul> <li class="c ...
- sql server 语句书写注意事项
1 Between在某些时候比IN 2 在必要是对全局或者局部临时表创建索引,有时能够提高速度,但不是一定会这样,因为索引也耗费大量的资源.他的创建同是实际表一样 3 尽量少用视图,它的效率低.对视 ...
- vue打包dist文件时,图片找不到
1.vue打包dist文件时,图片找不到,无法像在本地一样查看 问题描述: 本地代码:<div class="icon"><img :src="'../ ...
- 小程序Flex布局
容器属性 容器支持的属性有:display:通过设置display属性,指定元素是否为Flex布局.flex-direction:指定主轴方向,决定了项目的排列方式.flex-wrap:排列换行设置. ...
- Windows7用VirtualBox虚拟Ubuntu共享文件夹的终极方式
在Win7用VirtualBox虚拟机安装Ubuntu后,共享文件夹再也不用手工mount了 安装增强工具包 设置共享文件夹后 VB已经自动挂载Windows文件夹到 /media/sf_*** 目录 ...
- Dart运算符与语句格式
算术运算符 + 加 - 减 * 乘 / 除 ~/ 取整 % 取余 关系运算符 == 是否等于 != 是否不等于 > 是否大于 < 是否小于 >= 是否大于等于 <= 是否小于等 ...
- 【2017-05-30】WebForm文件上传。从服务端删除文件
用 FileUpload控件进行上传文件. <asp:FileUpload ID="FileUpload1" runat="server" /> ...
- jemeter正则
关联 jmeter关联用正则表达式 引用名称:随便取 正则表达式: 模板:$1$(这是固定的) 匹配数字:1 缺省值:默认不成功传的值 正则表达式在相应数据里面找 把变 ...
- RocketMQ原理分析 文章 精选【收集】
一. 推荐文章 1.以下来自OSChina的 mingxungu https://itzones.cn/ RocketMQ运维监控 RocketMQ刷盘策略 RocketMQ消息重试 RocketMQ ...