如何忽略已经在git中跟踪的文件 [英] how to ignore files that are already tracked in git

查看:157
本文介绍了如何忽略已经在git中跟踪的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过拉出原点a



并执行以下操作:

 错误:您对以下文件的本地更改将被合并覆盖:
src / .cproject
src / .project
src / navigate / navigate_main.c
请在您合并之前提交您的更改或隐藏它们。
正在取消

git状态显示:

 修改:.gitignore 
修改:src / .cproject
修改:src / .project
修改:src / navigate / navigate_main.c

我做了 git rm --cached src / .project 到前3,并且隐藏第四个



我再次拉动并取消了我的更改。但是,当我做拉来源a



我得到:

  M .gitignore 
U src / .cproject
M src / navigate / navigate_main.c
拉不可能,因为您有未合并的文件。
请将它们修复到工作树中,然后根据需要使用'git add / rm '
来标记分辨率,或使用'git commit -a'。

我怎样才能彻底清理这个?

git rm --cached src / .project 没有太大作用,除非你提交更改。为什么不只是 git stash 所有内容,然后 pull 隐藏弹出窗口,然后用 rm --cached


删除被忽略的文件

I tried to pull origin a.

and go the following:

error: Your local changes to the following files would be overwritten by merge:
    src/.cproject
    src/.project
    src/navigate/navigate_main.c
Please, commit your changes or stash them before you can merge.
Aborting

git status showed:

    modified:   .gitignore
modified:   src/.cproject
modified:   src/.project
modified:   src/navigate/navigate_main.c

I did git rm --cached src/.project to the first 3, and stashed the 4th

I did pull again and unstashed my changes.

however when I do pull origin a

I get:

M   .gitignore
U   src/.cproject
M   src/navigate/navigate_main.c
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.

how can I clean this once and for all?

解决方案

Your git rm --cached src/.project doesn't do much good unless you commit the change. Why not just git stash everything, then pull, stash pop, and then remove the ignored files with rm --cached?

这篇关于如何忽略已经在git中跟踪的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆