Reputation: 16267
I have cloned a repository on windows 8 and I have not modified any files. When I do a git status
I get the following though:
$ 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")
Now I want to checkout master but I am not allowed to do that:
$ 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
I have then tried:
git reset --hard
git clean -f
git checkout master
same error.
git checkout -- test.txt
git clean -f
git checkout master
same error.
So I still get the above error when I try to checkout master - and the test.txt file is still marked as being modified.
Below is the output from git config -l
(where I have removed some private entries)
$ 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/*
Any ideas on how to reset my repository?
Upvotes: 2
Views: 2446
Reputation: 736
just use git checkout --filename
or git checkout -- .
to discard all changes in modified files
Upvotes: 0
Reputation: 25119
First ensure test.txt
is not in .gitignore
(i.e. you have not added it).
Then do
git rm test.txt
git checkout -- test.txt
Add a -f
if you like
The rm
will get around any line ending changes
Finally you can
git reset --hard
git checkout master
etc.
Upvotes: 0