首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >git状态工作目录无提交,工作目录清理,添加,提交不去。

git状态工作目录无提交,工作目录清理,添加,提交不去。
EN

Stack Overflow用户
提问于 2018-07-06 21:58:22
回答 1查看 1.2K关注 0票数 1

-我也有同样的问题,但解决办法似乎行不通。

我克隆了一个新的存储库。我用git checkout -b b创建了一个新的分支,我们在其中一个目录中更新了我们的文件,叫做GAWBE c。我们推到那个分支d了吗?在github.com站点上检查了这个分支,很好。

然后,我必须将不同目录中的文件更新到主分支。调用PDBE目录--因此,我调用了

  1. git结账母版
  2. 转到PDBE目录
  3. 更新了几个文件
  4. git状态(我收到支部师父的消息了吗? (如上文所述,nothing to commit, working directory clean )
  5. 我做了git branch --set-upstream-to origin/master得到了消息Branch master set up to track remote branch master from origin. f,然后我又做了git状态,得到了# On branch master nothing to commit, working directory clean
  6. 我尝试了git pull origin From https://github.com/doctorleff/u3e *branch master -> FETCH_HEAD Already up to date. h。我再次尝试使用相同的working directoyr clean消息,git commit使用相同的消息。

不用说,我检查了我的.gitignore.git/info/exclude --在后者中没有--前者没有指定任何有问题的文件,都是.java。

这个问题37269222也尝试了rm -rf .git (问题37900326)也尝试了git日志作为第29578546期,得到了错误信息:致命:坏的默认修订‘头’

谢谢您建议我创建一个最小的文件来显示我的分支和git集线器的问题。

在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)用*.class创建了gitignore git add .gitignore git status告诉我

代码语言:javascript
复制
# 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"

答复如下:

代码语言:javascript
复制
[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推送-u原主它问我git的登录和密码,然后告诉我

代码语言:javascript
复制
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,添加了IncomeFile.java,git提交了-m“测试tomcat分支”

代码语言:javascript
复制
[TOMCAT 54f1b57] testing tomcat branch
 1 file changed, 1 insertion(+), 1 deletion (-)

14)再次git push origin tomcat,我被要求提供我的github用户名和密码。

然后它告诉我:

代码语言:javascript
复制
error: src refspect tomcat does not match any.
error: failed to push some refs to 'https://github.com/doctorleff/TR.git'

当我做git status的时候

代码语言:javascript
复制
$On branch TOMCAT
nothing to commit, working directory clean

如果我只键入git status,也是一样的

我试过了git check-ignore -v -- IncomeFile.java,只需要回提示符

我的测试目录现在似乎在工作。因此,我回到了我前面谈到的原始克隆存储库。

我遵循了StackOverflow第4089430期中的一些说明。(参见下面的链接)我比较了工作测试存储库和不工作的存储库的结果。本地存储库似乎失去了其远程的跟踪。

我在想,我是不是应该把git克隆到有缺陷的仓库里,让它们与世界重新连接起来。

与此同时,我通过克隆到另一台电脑Macintosh来解决我的问题。我能够正常使用远程存储库。因此,我不认为它有任何问题。我有一种稍微不太方便的方式来继续我们的项目。

[How can I determine the URL that a local Git repository was originally cloned from?

我有两个抄本(从脚本中略作编辑)。第一个是来自测试库,它显示了一些有用的东西--谢谢你让我试一下--

然后从真正的

代码语言:javascript
复制
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

因此,我试图返回到一个已损坏的存储库。

代码语言:javascript
复制
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)在那里也有一个.gitHEADrefs/heads/tomcat

我的另一个本地存储库副本sw/web/src也有一个.git --它的HEAD有行ref: refs/heads/master,但在这种情况下,该文件不存在。

正如建议的那样,我确实在这两个存储库上尝试了git remote -v。以下是sv的输出

代码语言:javascript
复制
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显示存储库已被无可救药地损坏:

代码语言:javascript
复制
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在这个存储库上创建了一个新的本地克隆。我在这两个分支之间来回走动,一切都很好。因此,请认为这件事已经结束,不能复制,也不再是原海报的问题。~

EN

回答 1

Stack Overflow用户

发布于 2018-07-07 05:15:20

我还检查了我的.gitignore.git/info/exclude --在后者中没有--前者没有指定任何有问题的文件,都是.java

二次核对:

代码语言:javascript
复制
git check-ignore -v -- PDBE/yourFile

有时候,gitignore规则可以来自其他来源(比如IDE)。

tomcat分支的第一个推送应该是git push -u origin tomcat

如果一个回购在另一个回购中,它就会变成一个嵌套的回购:它可能没有起源,而它的父(包括所述嵌套回购)有:

在每个文件夹中执行一个git remote -v

您可以使用git remote add origin /url/remote/repo添加远程源(嵌套回购文件夹中)。那样的话,这种推动可能会更有效。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51218103

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档