1

---I have the same problem but the fix does not seem to work.

I cloned a new repository. From it, I a. created a new branch with git checkout -b b. We updated our files in one of the directories, call it GAWBE c. did our push to that branch d. inspected the branch on the github.com site, It was fine

Then, I had to update files in a different directory to the master branch. Call the directory PDBE Thus, I did

  1. git checkout master
  2. went to the PDBE directory
  3. updated several files there
  4. did the git status (I got the message

    On branch master

    nothing to commit, working directory clean as indicated above)
  5. I did the git branch --set-upstream-to origin/master Got the message Branch master set up to track remote branch master from origin. f. I then did git status Again, I got # On branch master nothing to commit, working directory clean
  6. I tried git pull origin From https://github.com/doctorleff/u3e *branch master -> FETCH_HEAD Already up to date. h. I tried git status again with the same working directoyr clean message and git commit with the same message

Needless to say, I alo checked my .gitignore and .git/info/exclude Nothing in the latter--former does not specify any of the files in question, all .java

This as per the Issue 37269222 Also tried the rm -rf .git (Issue 37900326) also tried git log as per issue 29578546, got error message: fatal: bad default revision 'HEAD'


Thank you for suggesting that I create a minimal file to show the problem with my branches and git hub.

On github, I created a new repository. (It is marked public.) (It is doctorleff/TR

1) I created a directory TR to serve as my repository.
2) I put a single file there IncomeFile.java 3) git init Told me Initialized empty Git repository in /home/leffstudent/TR/.git 4) git add IncomeFile.java 5) Created gitignore with *.class 6) git add .gitignore 7) git status told me

# 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"

Response was:

[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 origin master It asked me for my git login and password, then told me

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 Told me: Switched to a new branch 'TOMCAT' 11) I changed IncomeFile.java slightly 12) git add IncomeFile.java 13) git commit -m "testing tomcat branch"

[TOMCAT 54f1b57] testing tomcat branch
 1 file changed, 1 insertion(+), 1 deletion (-)

14) git push origin tomcat Again, I was asked for my github username and passwrd.

Then it told me:

error: src refspect tomcat does not match any.
error: failed to push some refs to 'https://github.com/doctorleff/TR.git'

15) When I did a git status

$On branch TOMCAT
nothing to commit, working directory clean

Same thing if I simply type git status

I tried git check-ignore -v -- IncomeFile.java Just get back the prompt


My test directory now seems to be working. Thus, I went back to the original cloned repository about which I spoke earlier.

I followed some of the instructions in StackOverflow issue 4089430. (See link below) I compared the results on both the working TEST repository and the repository that does not work. It appears that the local repository lost track of its remote.

I was thinking, should I do a git clone right into the defective repositories to reconnect them to the world.

Meanwhile, I worked around my problem by cloning to a different computer, a Macintosh. I am able to work normally with the remote repository. Thus, I don't believe there is any problem with it. And I have, a slightly less convenient, way to proceed with our project.

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

I have two transcripts (edited slightly from script). The first is from the test repository, that shows things working-- thanks for asking me to try that--

and then from the real one

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

THUS, I then tried to go back to one of the repositories that was corrupted.

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

I also tried the git check-ignore -v -- on several files on the depository. This was as suggested in the answer.

It just returns--I assume that means that these files are not affected by any ignore rule.

____ response to VonC ___

In sv/web/src there is a .git subdirectory. FETCH_HEAD is zero bytes HEAD syas refs: refs/heads/master That file exists and contains a long hex code which I assume is a commit code, but I cannot find it at github.com.

The root (sv) also has a .git There, HEAD says refs/heads/tomcat

MY other local reposityory copy sw/web/src also has a .git Its HEAD has line ref: refs/heads/master But in that case, that file does not exist.


As suggested, I did try git remote -v on the two repositories in question. Here is the output for 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)

The second sw is showing that the repository is hopelessly corrupted:

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).

Since then, I have created a new local clone on this repository from github. I went back and forth between the two branches and everything is OK. Thus, please consider this matter closed as not reproducable and no longer a problem for original poster. ~

Laurence Leff
  • 76
  • 1
  • 8
  • Try to make a [MCVE] or something close to MCVE. Can you write a script which clones the repo to a new directory, `check-ignore`s as @VonC suggested, touches some file and then `status` again? Maybe even making a public fork, with removing all the files but a few files in the PDBE folder? I'd be willing to give it a try. – lexicore Jul 07 '18 at 08:33
  • Is there a .git in sv/web/src? – VonC Jul 17 '18 at 20:00
  • OK. I have updated the answer accordingly. – VonC Jul 18 '18 at 21:41

1 Answers1

1

I also checked my .gitignore and .git/info/exclude Nothing in the latter--former does not specify any of the files in question, all .java

Double-check with:

git check-ignore -v -- PDBE/yourFile

Sometime, gitignore rules can come from other sources (like an IDE).


The first push of the tomcat branch should be git push -u origin tomcat

If a repo is inside another one, it becomes a nested repo: it might not have an origin, while its parent (which includes said nested repo) have:
Do a git remote -v in each folder.
You can add a remote origin (in the nested repo folder) with git remote add origin /url/remote/repo. Then the push might work better.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250