我在系统中有一个git仓库。
当我在windows PowerShell中输入
这个问题是由什么引起的,我该如何解决?
提前致谢。
注意: 除了接受的答案外,考虑Ralf的答案,我发现让两个shell使用一个git是一个好主意。 - 使用
git status
时,会得到一个结果;而当我在windows bash中输入时,则会得到另一个结果。
更多详情请见图片。
如您所见,在Windows PowerShell中,git status
显示Nothing to commit
,而在Windows Bash中,相同的git status
显示您有未暂存的更改。
以下是两种操作下git version
的输出结果:
Windows Powershell:
git version 2.18.0.windows.1
Windows Bash:
git version 2.7.4
这里是一个git diff .idea/gradle.xml
的输出结果:
Powershell:
Bash:
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 7ac24c7..15dda04 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -1,18 +1,18 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="GradleSettings">
- <option name="linkedExternalProjectsSettings">
- <GradleProjectSettings>
- <option name="distributionType" value="DEFAULT_WRAPPED" />
- <option name="externalProjectPath" value="$PROJECT_DIR$" />
- <option name="modules">
- <set>
- <option value="$PROJECT_DIR$" />
- <option value="$PROJECT_DIR$/app" />
- </set>
- </option>
- <option name="resolveModulePerSourceSet" value="false" />
- </GradleProjectSettings>
- </option>
- </component>
+<?xml version="1.0" encoding="UTF-8"?>^M
+<project version="4">^M
+ <component name="GradleSettings">^M
+ <option name="linkedExternalProjectsSettings">^M
+ <GradleProjectSettings>^M
+ <option name="distributionType" value="DEFAULT_WRAPPED" />^M
+ <option name="externalProjectPath" value="$PROJECT_DIR$" />^M
+ <option name="modules">^M
+ <set>^M
+ <option value="$PROJECT_DIR$" />^M
+ <option value="$PROJECT_DIR$/app" />^M
+ </set>^M
+ </option>^M
+ <option name="resolveModulePerSourceSet" value="false" />^M
+ </GradleProjectSettings>^M
+ </option>^M
+ </component>^M
</project>
\ No newline at end of file
:
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 7ac24c7..15dda04 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -1,18 +1,18 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="GradleSettings">
- <option name="linkedExternalProjectsSettings">
- <GradleProjectSettings>
- <option name="distributionType" value="DEFAULT_WRAPPED" />
- <option name="externalProjectPath" value="$PROJECT_DIR$" />
- <option name="modules">
- <set>
- <option value="$PROJECT_DIR$" />
- <option value="$PROJECT_DIR$/app" />
- </set>
- </option>
- <option name="resolveModulePerSourceSet" value="false" />
- </GradleProjectSettings>
- </option>
- </component>
+<?xml version="1.0" encoding="UTF-8"?>^M
+<project version="4">^M
+ <component name="GradleSettings">^M
+ <option name="linkedExternalProjectsSettings">^M
+ <GradleProjectSettings>^M
+ <option name="distributionType" value="DEFAULT_WRAPPED" />^M
+ <option name="externalProjectPath" value="$PROJECT_DIR$" />^M
+ <option name="modules">^M
+ <set>^M
+ <option value="$PROJECT_DIR$" />^M
+ <option value="$PROJECT_DIR$/app" />^M
+ </set>^M
+ </option>^M
+ <option name="resolveModulePerSourceSet" value="false" />^M
+ </GradleProjectSettings>^M
+ </option>^M
+ </component>^M
</project>
\ No newline at end of file
:...skipping...
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 7ac24c7..15dda04 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -1,18 +1,18 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="GradleSettings">
- <option name="linkedExternalProjectsSettings">
- <GradleProjectSettings>
- <option name="distributionType" value="DEFAULT_WRAPPED" />
- <option name="externalProjectPath" value="$PROJECT_DIR$" />
- <option name="modules">
- <set>
- <option value="$PROJECT_DIR$" />
- <option value="$PROJECT_DIR$/app" />
- </set>
- </option>
- <option name="resolveModulePerSourceSet" value="false" />
- </GradleProjectSettings>
- </option>
- </component>
+<?xml version="1.0" encoding="UTF-8"?>^M
+<project version="4">^M
+ <component name="GradleSettings">^M
+ <option name="linkedExternalProjectsSettings">^M
+ <GradleProjectSettings>^M
+ <option name="distributionType" value="DEFAULT_WRAPPED" />^M
+ <option name="externalProjectPath" value="$PROJECT_DIR$" />^M
+ <option name="modules">^M
+ <set>^M
+ <option value="$PROJECT_DIR$" />^M
+ <option value="$PROJECT_DIR$/app" />^M
+ </set>^M
+ </option>^M
+ <option name="resolveModulePerSourceSet" value="false" />^M
+ </GradleProjectSettings>^M
+ </option>^M
+ </component>^M
</project>
\ No newline at end of file
~
我可以看到这完全不同。
这是 git config -l
命令的输出结果:Powershell:
core.symlinks=true
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=D:/Apps/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
user.name=Mahdi
user.email=mahdi.malvandi@pushe.co
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
remote.origin.url=git@github.com:mahdi-malv/shahpari_market.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.setMainActivity.remote=origin
branch.setMainActivity.merge=refs/heads/setMainActivity
branch.networkSetup.remote=origin
branch.networkSetup.merge=refs/heads/networkSetup
branch.compNav.remote=origin
branch.compNav.merge=refs/heads/compNav
branch.presenter.remote=origin
branch.presenter.merge=refs/heads/presenter
branch.mainUi.remote=origin
branch.mainUi.merge=refs/heads/mainUi
branch.downloadManager.remote=origin
branch.downloadManager.merge=refs/heads/downloadManager
branch.category.remote=origin
branch.category.merge=refs/heads/category
:
Bash:
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
remote.origin.url=git@github.com:mahdi-malv/shahpari_market.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.setMainActivity.remote=origin
branch.setMainActivity.merge=refs/heads/setMainActivity
branch.networkSetup.remote=origin
branch.networkSetup.merge=refs/heads/networkSetup
branch.compNav.remote=origin
branch.compNav.merge=refs/heads/compNav
branch.presenter.remote=origin
branch.presenter.merge=refs/heads/presenter
branch.mainUi.remote=origin
branch.mainUi.merge=refs/heads/mainUi
branch.downloadManager.remote=origin
branch.downloadManager.merge=refs/heads/downloadManager
branch.category.remote=origin
branch.category.merge=refs/heads/category
branch.setCategory.remote=origin
branch.setCategory.merge=refs/heads/setCategory
branch.searchFix.remote=origin
branch.searchFix.merge=refs/heads/searchFix
branch.homeMoreAPI.remote=origin
branch.homeMoreAPI.merge=refs/heads/homeMoreAPI
branch.userApp.remote=origin
branch.userApp.merge=refs/heads/userApp
branch.allApps.remote=origin
branch.allApps.merge=refs/heads/allApps
branch.settings.remote=origin
branch.settings.merge=refs/heads/settings
branch.autoUpdate.remote=origin
branch.autoUpdate.merge=refs/heads/autoUpdate
branch.tempStore.remote=origin
branch.tempStore.merge=refs/heads/tempStore
branch.fixIcon.remote=origin
branch.fixIcon.merge=refs/heads/fixIcon
branch.changeAd.remote=origin
branch.changeAd.merge=refs/heads/changeAd
branch.updateAndAnal.remote=origin
branch.updateAndAnal.merge=refs/heads/updateAndAnal
branch.merge1.remote=origin
branch.merge1.merge=refs/heads/merge1
branch.fixV1beta.remote=origin
branch.fixV1beta.merge=refs/heads/fixV1beta
branch.sendDevice.remote=origin
branch.sendDevice.merge=refs/heads/sendDevice
branch.newIcon.remote=origin
branch.newIcon.merge=refs/heads/newIcon
这个问题是由什么引起的,我该如何解决?
提前致谢。
注意: 除了接受的答案外,考虑Ralf的答案,我发现让两个shell使用一个git是一个好主意。 - 使用
sudo apt remove git
从bash中删除Git。
- 在bash的$PATH中添加git.exe的路径
。
- 为了简单起见,使用alias git='git.exe'
可以像以前一样使用Git。
您可以对其他可能遇到此问题的内容(例如Python等)执行此操作。
git diff .idea/gradle.xml
的输出是什么?此外,对于两个环境,git version
的输出是什么?你能把两者的输出都添加到原始问题中吗? - eftshift0git version
和git diff .idea/gradle.xml
?在哪里? - eftshift0diff
在里面,是的,也很好看到。 - Tim Biegeleisengit version
返回:git version 2.18.0.windows.1
。而对于Windows Bash
,它将是git version 2.7.4
。 - Mahdi-Malvgit config -l
对于两者都可以有所帮助。 - eftshift0