Home  >  Q&A  >  body text

服务器 - git 部署代码,出现untracked files的代码

使用git同步代码到服务器,从特性分支切到 master 或者其他新分支,再执行 git status 提示有 untracked files ,这几个 untracked files 都是已被删除的.

[www@iZ94 fl.com]$ git status
# On branch develop
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       images/an_page_h5-06.png~HEAD
#       images/an_page_h5-06.png~HEAD_0
#       images/an_page_h5-07.png~HEAD
#       images/an_page_h5-07.png~HEAD_0
#       images/an_page_h5-08.png~HEAD
#       images/an_page_h5-08.png~HEAD_0
#       images/an_page_h5-09.png~HEAD
#       images/an_page_h5-09.png~HEAD_0
nothing added to commit but untracked files present (use "git add" to track)
[www@iZ94 fl.com]$ 

[www@iZ94 fl.com]$ git reset --hard origin master
fatal: Cannot do hard reset with paths.
[www@iZ94 fl.com]$ git reset --hard remotes/origin/develop
HEAD is now at 6ac5b22 Merge branch 'PD_MC-414_Ma1-2' into 'develop'

这几个图片文件是不需要的。本地是WIN,不区分大小写,大小写写错。提交到LINUX,区分大小写,后来改了,但缓存里面的一直无法删除掉。现在切到其他的分支就有这样的提示,使用 git reset --hard remotes/origin/master,如何才可以强制变为干净的分支。

阿神阿神2703 days ago666

reply all(2)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-02 09:34:41

    Git reset is to restore the contents of the temporary storage area. This content is not in the temporary storage area. You can use git clean to clean it, or delete these files directly, or use git checkout to restore the contents of the workspace!

    reply
    0
  • PHPz

    PHPz2017-05-02 09:34:41

    Visually check that these files are generated during the running of your program. You can delete them directly. The best solution is to place the generated temporary content in some specific directories, and then add this directory to the .gitignorefile

    reply
    0
  • Cancelreply