---我也有同样的问题,但是修复似乎不起作用。
我克隆了一个新的存储库。从它,我
一种。用git checkout -b
创建了一个新分支
b。我们在一个目录中更新了文件,将其命名为GAWBE
C。我们推送到那个分支了吗
d。检查了github.com网站上的分支,很好
然后,我不得不将文件更新到master分支的另一个目录中。 调用目录PDBE 因此,我做到了
PDBE
目录nothing to commit, working directory clean
如上所述)git branch --set-upstream-to origin/master
得到了消息
Branch master set up to track remote branch master from origin.
F。然后我做了git status
再说一次
# On branch master
nothing to commit, working directory clean
git pull origin
From https://github.com/doctorleff/u3e
*branch master -> FETCH_HEAD
Already up to date.
H。我再次使用相同的git status
消息尝试了working directoyr clean
和git commit
并显示相同的消息不用说,我也检查了.gitignore
和.git/info/exclude
后者没有任何内容-前者未指定任何相关文件,
所有.java
根据问题37269222 还尝试了rm -rf .git(问题37900326) 还按照问题29578546尝试了git log,得到了错误消息: 致命:默认版本“ HEAD”错误
感谢您建议我创建一个最小文件来显示问题 与我的分支机构和git hub。
在github上,我创建了一个新的存储库。 (已标记为公开。)
(它是doctorleff/TR
1)我创建了一个目录TR
作为我的存储库。
2)我在其中放置了一个文件IncomeFile.java
3)git init
告诉我Initialized empty Git repository in /home/leffstudent/TR/.git
4)git add IncomeFile.java
5)使用gitignore
创建了*.class
6)git add .gitignore
7)git status
告诉我
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: .gitignore
# new file: IncomeFile.java
8) `git commit -m "first commit"
响应为:
[master (root-commit) 6e71c52] first commit
2 files changed, 37 insertions(+)
create mode 100644 .gitignore
create mode 100644 IncomeFile.java
8)git remote add origin https:/github.com/doctorleff/TR.git
9)git push -u原始主机
它要求我输入我的git登录名和密码,然后告诉我
Counting ojbects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done
Writing objects: 100% (4/4), 681 bytes | 0 bytes/s, done.
10)git checkout -b TOMCAT
告诉我:
Switched to a new branch 'TOMCAT'
11)我稍微更改了IncomeFile.java
12)git添加IncomeFile.java
13)git commit -m“测试tomcat分支”
[TOMCAT 54f1b57] testing tomcat branch
1 file changed, 1 insertion(+), 1 deletion (-)
14)git push origin tomcat
再次,我被要求提供我的github用户名和密码。
然后它告诉我:
error: src refspect tomcat does not match any.
error: failed to push some refs to 'https://github.com/doctorleff/TR.git'
15)我做了git status
$On branch TOMCAT
nothing to commit, working directory clean
如果我只键入git status
我尝试了git check-ignore -v -- IncomeFile.java
只需返回提示
我的测试目录现在似乎正在运行。因此,我回到了之前谈到的原始克隆存储库。
我遵循了 StackOverflow问题4089430。(请参阅下面的链接) 我在工作的TEST存储库和 无效的存储库。看来是本地存储库 迷路了。
我在想,我应该对缺陷者进行git clone吗? 存储库以将它们重新连接到世界。
与此同时,我通过克隆到另一台计算机来解决问题, Macintosh。我可以正常工作 远程存储库。因此,我不认为这有任何问题。 而且,我有一种不太方便的方式来进行我们的项目。
[How can I determine the URL that a local Git repository was originally cloned from?
我有两个成绩单(从脚本中略作编辑)。首先是从 测试存储库,显示工作正常- 感谢您要求我尝试-
然后是真实的
cd TR
git remote show origin
* remote origin
Fetch URL: https://github.com/doctorleff/TR.git
Push URL: https://github.com/doctorleff/TR.git
HEAD branch: master
Remote branches:
TOMCAT tracked
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local refs configured for 'git push':
TOMCAT pushes to TOMCAT (up to date)
master pushes to master (up to date)
git remote show origin
* remote origin
Fetch URL: https://github.com/doctorleff/TR.git
Push URL: https://github.com/doctorleff/TR.git
HEAD branch: master
Remote branches:
TOMCAT tracked
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local refs configured for 'git push':
TOMCAT pushes to TOMCAT (up to date)
master pushes to master (up to date)
git status
# On branch master
# 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: IncomeFile.java
#
no changes added to commit (use "git add" and/or "git commit -a")
git checkout -- IncomeFile.java
git checkout TOMCAT
Switched to branch 'TOMCAT'
git status
# On branch TOMCAT
nothing to commit, working directory clean
VI IncomeFile.java
git commit -m "changed mC to Mc"
# On branch TOMCAT
# 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: IncomeFile.java
#
no changes added to commit (use "git add" and/or "git commit -a")
git add IncomeFile.java
git commit -m "changed mC to Mc"
[TOMCAT 7b842b0] changed mC to Mc
1 file changed, 1 insertion(+), 1 deletion(-)
push origin
fatal: The current branch TOMCAT has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin TOMCAT
git push --setu-upstream origin TOMCAT
Username for 'https://github.com': doctorleff
Password for 'https://doctorleff@github.com':
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 33% (1/3)
Compressing objects: 66% (2/3)
Compressing objects: 100% (3/3)
Compressing objects: 100% (3/3), done.
Writing objects: 33% (1/3)
Writing objects: 66% (2/3)
Writing objects: 100% (3/3)
Writing objects: 100% (3/3), 323 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 0% (0/1) remote: Resolving deltas: 100% (1/1) [K
remote: Resolving deltas: 100% (1/1), completed with 1 local object.[K
To https://github.com/doctorleff/TR.git
ff102ee..7b842b0 TOMCAT -> TOMCAT
Branch TOMCAT set up to track remote branch TOMCAT from origin.
git add IncomeFile.java
"change M[KCa to aC"
[TOMCAT 1a6739c] change Ca to aC
1 file changed, 1 insertion(+), 1 deletion(-)
git push origin
Username for 'https://github.com': doctorleff
Password for 'https://doctorleff@github.com':
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 33% (1/3)
Compressing objects: 66% (2/3)
Compressing objects: 100% (3/3)
Compressing objects: 100% (3/3), done.
Writing objects: 33% (1/3)
Writing objects: 66% (2/3)
Writing objects: 100% (3/3)
Writing objects: 100% (3/3), 324 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 0% (0/1) [K
remote: Resolving deltas: 100% (1/1) Resolving deltas: 100% (1/1), completed with 1 local object.[K
To https://github.com/doctorleff/TR.git
7b842b0..1a6739c TOMCAT -> TOMCAT
因此,然后我尝试返回损坏的存储库之一。
cd sv/web/src
git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
#LONG LIST OF FILES REMOVED for clarity
#
# Test.java
nothing added to commit but untracked files present (use "git add" to track)
git add Test.java
git commit -m "testing with Test.java"
[master (root-commit) 96c329f] testing with Test.java
1 file changed, 70 insertions(+)
create mode 100644 Test.java origin
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
git push --set-upstream origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists
____________________________________________
git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# $
# .RatingEntryServletNew.java.swp
# 11in35tr.xls
# AdminFrontServlet.class
# AdminFrontServlet.java
# AgreementBackend.class
-- REST OF LONG LIST OF FILES GIVEN DELETED FOR BREVITY
nothing added to commit but untracked files present (use "git add" to track)
git remote show origin
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
git config --get remote.origin.url
git remote -v
git ls-remote --get-r[Kurl
fatal: No remote configured to list refs from.
git ls-remote --get-url origin
origin
我还在存储库中的多个文件上尝试过git check-ignore -v --
。
如答案中所建议。
它只是返回-我认为这意味着这些文件不受 任何忽略规则。
____对VonC的答复___
在sv/web/src
中有一个.git
子目录。 FETCH_HEAD
为零字节
HEAD
syas refs: refs/heads/master
该文件存在且包含一个很长的文件
我假定的十六进制代码是提交代码,但是我无法在github.com上找到它。
根(sv
)也有一个.git
,HEAD
表示refs/heads/tomcat
我的其他本地存储库副本
sw/web/src
也有一个.git
其HEAD
有一个
行ref: refs/heads/master
,但在那种情况下,该文件不存在。
根据建议,我确实尝试了git remote -v
在以下两个存储库中
题。这是sv
git remote -v
githubrepo https://github.com/doctorleff/u3e.git (fetch)
githubrepo https://github.com/doctorleff/u3e.git (push)
origin https://github.com/doctorleff/u3e.git (fetch)
origin https://github.com/doctorleff/u3e.git (push)
第二个sw
显示存储库无可救药地损坏了:
git remote -v
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
从那时起,我从github在此存储库上创建了一个新的本地克隆。 我在两个分支之间来回移动,一切正常。 因此,请将此事视为不可复制且不再存在 原始海报的问题。 〜
答案 0 :(得分:1)
我还检查了
.gitignore
和.git/info/exclude
中的所有内容-前者未指定任何有问题的文件,全部为.java
再次检查:
git check-ignore -v -- PDBE/yourFile
有时候,gitignore规则可以来自其他来源(例如IDE)。
tomcat分支的第一次推送应该是git push -u origin tomcat
如果某个存储库位于另一个存储库中,则它将成为嵌套存储库:它可能没有源,而其父项(包括所述嵌套存储库)具有:
在每个文件夹中执行git remote -v
。
您可以使用git remote add origin /url/remote/repo
添加一个远程源(在嵌套的repo文件夹中)。然后,推送可能会更好。