我在Windows 8上克隆了一个存储库,但我没有修改任何文件。当我做git status
时,我得到以下结果:
$ git st
On branch myFeature
Your branch is up-to-date with 'origin/myFeature'.
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: test.txt
no changes added to commit (use "git add" and/or "git commit -a")
现在我想结账大师,但我不允许这样做:
$ git co master
error: Your local changes to the following files would be overwritten by checkout:
test.txt
Please, commit your changes or stash them before you can switch branches.
Aborting
然后我尝试了:
git reset --hard
git clean -f
git checkout master
同样的错误。
git checkout -- test.txt
git clean -f
git checkout master
同样的错误。
所以当我尝试签出master时仍然会出现上述错误 - 而且test.txt文件仍被标记为已修改。
以下是git config -l
的输出(我删除了一些私人条目)
$ git config -l
core.symlinks=false
core.autocrlf=false
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
core.autocrlf=false
core.editor="C:/Program Files (x86)/GitExtensions/GitExtensions.exe" fileeditor
core.longpaths=true
core.packedgitlimit=128m
core.packedgitwindowsize=128m
core.hidedotfiles=false
alias.st=status
alias.co=checkout
merge.tool=kdiff3
diff.guitool=kdiff3
mergetool.kdiff3.path=C:/Program Files/KDiff3/kdiff3.exe
difftool.kdiff3.path=C:/Program Files/KDiff3/kdiff3.exe
push.default=simple
pack.deltacachesize=128m
pack.packsizelimit=128m
pack.windowmemory=128m
color.branch.upstream=cyan
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=false
core.autocrlf=false
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
有关如何重置我的存储库的任何想法?
答案 0 :(得分:0)
首先确保test.txt
不在.gitignore
中(即您尚未添加)。
然后做
git rm test.txt
git checkout -- test.txt
如果您愿意,可以添加-f
rm
将绕过任何结束更改的行
最后你可以
git reset --hard
git checkout master
等
答案 1 :(得分:0)
只需使用git checkout --filename
或git checkout -- .
放弃修改文件中的所有更改