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>… 命令参 ...
随机推荐
- Linux常用命令(自用)
1 抓包 tcpdump port 5060 and host 192.168.1.180 tcpdump -i ethx -w 1.pcap -s 0 2. 查看硬盘使用情况 df ./ 3.查看进 ...
- java之JVM学习--简单了解GC算法
JVM内存组成结构: (1)堆 所有通过new创建的对象都是在堆中分配内存,其大小可以通过-Xmx和-Xms来控制,堆被划分为新生代和旧生代,新生代又被进一步划分为Eden和Survivor区.Sur ...
- 解决织梦5.7添加新变量出现:Request var not allow!的办法
找到:根目录->include->common.inc.phpif( strlen($svar)>0 && preg_match('#^(cfg_|GLOBALS|_ ...
- 【异常】Cannot run program "git" (in directory "/mnt/software/azkaban-3.79.0"): error=2, No such file or directory
1 安装azkaban异常 cloudera-scm@cdh4 azkaban-3.79.0]$ ./gradlew build -x test Parallel execution with con ...
- Django_05_模板
模板 如何向请求者返回一个漂亮的页面呢?肯定需要用到html.css,如果想要更炫的效果还要加入js,问题来了,这么一堆字段串全都写到视图中,作为HttpResponse()的参数吗?这样定义就太麻烦 ...
- linux 设备驱动与应用程序异步通知
一.异步通知机制简介 异步通知机制的意思:一旦设备准备就绪,可以主动的通知应用程序进行相应的操作,从而使得应用程序不必去查询设备的状态. 异步通知比较准确的称谓是"信号驱动的异步IO&quo ...
- Collection 和 Collections 有什么区别?(未完成)
Collection 和 Collections 有什么区别?(未完成)
- C#信号量(Semaphore,SemaphoreSlim)
Object->MarshalByRefObject->WaitHandle->Semaphore 1.作用: 多线程环境下,可以控制线程的并发数量来限制对资源的访问 2.举例: S ...
- HashMap源码分析三
HashMap的源码,在jdk1.5中相比jdk1.4,改动不大,有几个方面 1 jdk1.5中引入了范型,在HashMap中也有体现 2 引入了另一个hash值的计算方式,不过默认是关闭状态 ...
- new函数
可以通过new函数直接创建一个类型的指针 变量名:=new(Type) 使用new函数创建的指针已有指向,可以使用*指针对象进行赋值. func main() { a := new(int) fmt. ...