我有一个git存储库,由于某种原因显示本地更改,我无法恢复。从一个刚刚克隆的repo我看到一个配置文件随着git diff
中的以下差异而改变C:\Projects\NewUI>git diff
diff --git a/EPFR.CountryFlows.Tests/app.config b/EPFR.CountryFlows.Tests/app.config
index d7256aa..7e1d79c 100644
--- a/EPFR.CountryFlows.Tests/app.config
+++ b/EPFR.CountryFlows.Tests/app.config
@@ -1,11 +1,17 @@
<U+FEFF><?xml version="1.0" encoding="utf-8"?>
<configuration>
- <runtime>
- <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
- <dependentAssembly>
- <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
- </dependentAssembly>
- </assemblyBinding>
- </runtime>
+ <configSections>
+ <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+ <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ </configSections>
+ <entityFramework>
+ <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
+ <parameters>
+ <parameter value="mssqllocaldb" />
+ </parameters>
+ </defaultConnectionFactory>
+ <providers>
+ <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+ </providers>
+ </entityFramework>
</configuration>
\ No newline at end of file
当我运行git reset
或git checkout
时,没有任何变化。如果我run git reset --hard
我得到以下结果
C:\Projects\NewUI>git diff
diff --git a/EPFR.CountryFlows.Tests/App.config b/EPFR.CountryFlows.Tests/App.config
index 7e1d79c..d7256aa 100644
--- a/EPFR.CountryFlows.Tests/App.config
+++ b/EPFR.CountryFlows.Tests/App.config
@@ -1,17 +1,11 @@
<U+FEFF><?xml version="1.0" encoding="utf-8"?>
<configuration>
- <configSections>
- <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
- </configSections>
- <entityFramework>
- <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
- <parameters>
- <parameter value="mssqllocaldb" />
- </parameters>
- </defaultConnectionFactory>
- <providers>
- <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
- </providers>
- </entityFramework>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
</configuration>
\ No newline at end of file
显示添加的行和已删除的行已切换。运行git reset --hard
将导致这两部分代码在添加和删除之间来回切换。我做错了什么?
答案 0 :(得分:1)
git reset --hard HEAD^
这里是HEAD - 我目前正在进行的提交; HEAD ^ - commit的父级;这将在本地删除您的更改
答案 1 :(得分:1)
原来问题是,某些人已经提交了app.Config,其他人已经提交了App.config,您可以在上面的输出中看到。 Git可以解决这个问题,因为Linux有区分大小写的文件,但Windows没有。我从这个问题中找到了以下答案和修复
_pattern = "abba" #raw_input().strip()
_string = "catdogdogcat" #raw_input().strip()
hm = {}
rxp = ""
c = 1
for x in _pattern:
if x in hm:
rxp += hm[x]
continue
else:
rxp += "(.+)"
hm[x]="\\" + str(c)
c+=1
print rxp
print re.match(rxp,_string)
防止问题再次发生
git mv -f app.config App.config
git commit -m 'fix case'