Git的行为 - 未添加的文件被添加 [英] Git acting up - unadded files that are added

查看:106
本文介绍了Git的行为 - 未添加的文件被添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $ git checkout master 
错误:以下未跟踪的工作树文件将被checko
ut覆盖:
Documentation / packages / CoreTheme_Template_helpers.html
Documentation / packages / default.html
请在您之前移动或移除它们可以切换分支。
正在取消

好的,

 $ git status 
#分支beta
没有提交,工作目录干净

发生了什么事?

解决方案

工作树中的所有未跟踪文件都匹配 .gitignore 格式如此 git status 忽略它们。



开分支 master ,但是,这两个文件在当前工作树中未被跟踪并被忽略。 (Git不会忽略跟踪的文件)。因此,检查 master 会压制工作树中未提交的内容,而git也不会这样做。


So doing the following, on a branch called "beta":

$ git checkout master
error: The following untracked working tree files would be overwritten by checko
ut:
        Documentation/packages/CoreTheme_Template_helpers.html
        Documentation/packages/default.html
Please move or remove them before you can switch branches.
Aborting

Ok,

$ git status
# On branch beta
nothing to commit, working directory clean 

Whats going on?

解决方案

All the untracked files in your worktree match a .gitignore pattern so git status ignores them.

On branch master, though, those two files, which exist untracked and ignored in your current worktree, are tracked. (Git will not ignore tracked files). So checking out master would stomp on uncommitted content in your worktree, and git won't do that either.

这篇关于Git的行为 - 未添加的文件被添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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