How can I undo adding a new file to git?
本问题已经有最佳答案,请猛点这里访问。
我做了
要提交的更改:(使用"git reset head…"来解除锁定)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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 |
我做了
1 2 3 4 5 6 7 8 9 | 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 |
号
然后我意识到我不想让ecx1〔2〕去回购这个文件:
1 | project.xcworkspace/xcuserdata/M.xcuserdatad/WorkspaceSettings.xcsettings |
所以在我执行
你的问题有答案:
1 | Changes to be committed: (use"git reset HEAD ..." to unstage) |
要取消文件的存储,请键入:
1 | git reset HEAD project.xcworkspace/xcuserdata/M.xcuserdatad/WorkspaceSettings.xcsettings |
号
我可以补充一点,这不会撤消您对文件所做的更改。