git - 如何从远程拉,而在本地忽略文件?
问题描述
在 git 中,我根据对question的回答使用 .git/info/exclude 忽略了本地文件。但现在我不能从远程拉,这是我得到的错误:
git pull
error: Your local changes to the following files would be overwritten by
merge: ignoredFile
Please commit your changes or stash them before you merge.
所以我尝试提交这个文件:
git commit -am "Message"
On branch master
Your branch is behind 'origin/master' by 4 commits, and can be fast-
forwarded.
(use "git pull" to update your local branch)
nothing to commit, working tree clean
所以问题就像标题一样,如何保持存储库更新(git pull),同时忽略本地的特定文件。
编辑:我跑了赞扬:
git update-index --assume-unchanged ignoredFile
在 git 拉之前。
编辑2:
git pull --rebase
error: Your local changes to the following files would be overwritten by merge:
ignoredFile
Please commit your changes or stash them before you merge.
Aborting
Updating 0f37f00b..5ccc1b0a
First, rewinding head to replay your work on top of it...
error: Your local changes to the following files would be overwritten by checkout:
ignoredFile
Please commit your changes or stash them before you switch branches.
Aborting could not detach HEAD
解决方案
可能您正在寻找:
$ git pull --rebase
这将更新您的分支并在不创建新分支的情况下向前移动您的更改,但不会忽略您的本地文件,以便您可以在需要时推送它们或从中创建分支。
推荐阅读
- html - 为什么 Chrome 不更新内联块的宽度
- microsoft-graph-api - 尝试使用 Outlook REST API 在日历上创建事件时获取错误代码“ErrorIrresolvableConflict”响应
- firebase - 将 react-native 应用程序连接到 firebase 的最佳方式是什么?
- ansible - Ansible 角色断言在基于清单组中的主机计数构建的 var 上失败
- r - R中的循环管道运算符
- c++ - 如何避免指针超出范围的 C++ 分段错误(多态性)
- java - 如何在没有比较器的Java中使用MergeSort对对象数组进行排序
- javascript - 跨多个页面的多个 iframe 不同?
- sas - 在proc sql中按多个变量分组时为缺失值添加行
- python - 在 RPN 中显示预测的 boxex(Tensorflow Faster-RCNN)