我怎样才能取消添加一个新的文件到混帐? [英] How can I undo adding a new file to git?

查看:119
本文介绍了我怎样才能取消添加一个新的文件到混帐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了 git status ,并看到一些新文件,例如:

要提交的更改:
(使用git reset HEAD ...来取消)

pre $ 新建文件:project / swiftFile1.swift
新文件:projec / swiftFile2.swift

不会为commit提交更改:
(使用git add< file> ...更新将提交的内容)
(使用git checkout - < file>放弃工作目录中的更改)

修改:project.xcodeproj / project.pbxproj
修改:项目。 xcworkspace / xcuserdata / M.xcuserdatad / UserInterfaceState.xcuserstate

未记录的文件:
(使用git add< file> ...包含在将要提交的内容中)

project.xcworkspace / xcuserdata / M.xcuserdatad / WorkspaceSettings.xcsettings

code> git add -A ,它添加到git上面的所有文件,现在我看到:

 更改为提交编辑:
(使用git reset HEAD< file> ...停用)

修改:project.xcodeproj / project.pbxproj
修改:project.xcworkspace / xcuserdata / M.xcuserdatad / UserInterfaceState.xcuserstate
新文件:project.xcworkspace / xcuserdata / M.xcuserdatad / WorkspaceSettings.xcsettings
修改:project / Base.lproj / Main.storyboard
修改: project / swiftFile1.swift
修改:project / swiftFile2.swift

然后我意识到我不希望推送到这个文件的回购:

 项目.xcworkspace / xcuserdata / M.xcuserdatad / WorkspaceSettings.xcsettings 

所以在执行 git push 我可以做些什么来停止提交这个特定的文件(但不能将它从我的硬盘中移除)? / b>你有你的问题的答案:

pre $ 要提交的更改:(使用git reset HEAD ...取消)

要取消文件输入:

  git的复位HEAD project.xcworkspace / xcuserdata / M.xcuserdatad / WorkspaceSettings.xcsettings 

我可能会补充说这不会撤消您对该文件所做的更改。


I did git status and saw a bunch of new files, e.g.:

Changes to be committed: (use "git reset HEAD ..." to unstage)

    new file:   project/swiftFile1.swift
    new file:   projec/swiftFile2.swift

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   project.xcodeproj/project.pbxproj
    modified:   project.xcworkspace/xcuserdata/M.xcuserdatad/UserInterfaceState.xcuserstate

    Untracked files:
  (use "git add <file>..." to include in what will be committed)

    project.xcworkspace/xcuserdata/M.xcuserdatad/WorkspaceSettings.xcsettings

I did git add -A and it added to git all the files above, now I see there:

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   project.xcodeproj/project.pbxproj
    modified:   project.xcworkspace/xcuserdata/M.xcuserdatad/UserInterfaceState.xcuserstate
    new file:   project.xcworkspace/xcuserdata/M.xcuserdatad/WorkspaceSettings.xcsettings
    modified:   project/Base.lproj/Main.storyboard
    modified:   project/swiftFile1.swift
    modified:   project/swiftFile2.swift

And then I realized I don't want to push to the repo this file:

project.xcworkspace/xcuserdata/M.xcuserdatad/WorkspaceSettings.xcsettings

so before I do git push what could I do to stop committing this particular file (but not remove it from my hard drive)?

解决方案

You have the answer in your question:

Changes to be committed: (use "git reset HEAD ..." to unstage)

To unstage the file, type:

git reset HEAD project.xcworkspace/xcuserdata/M.xcuserdatad/WorkspaceSettings.xcsettings 

I might add that this does not undo the changes you made to the file.

这篇关于我怎样才能取消添加一个新的文件到混帐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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