Git – Error – “Git Push” – “fatal: unable to read” // “fatal: the remote end hung up unexpectedly”

 

Background

Unable to “push” a Git Repository.

Git Commands

Git Push

Command


git push

Output

Output – Image

unableToRead.01.20191126.0348AM.PNG

Output – Text

>git push
Enumerating objects: 25, done.
Counting objects: 100% (25/25), done.
Delta compression using up to 4 threads
Compressing objects: 100% (15/15), done.
fatal: unable to read ae2f13a80be0345c2a7dfedbb4cb50b3eb248057
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly
error: failed to push some refs to 'https://github.com/DanielAdeniji/Set.git'

TroubleShooting & Remediation

 

Git Commands

Connectivity verification and Object Validation

Git Fsck ( git-fsck ) – Verifies the connectivity and validity of the objects in the database

Command

git fsck --full

Output
Output – Image

gitfsck.01.20191116.0352AM.PNG

Output – Text

>git fsck --full
Checking object directories: 100% (256/256), done.
broken link from    tree 153e9de898634ff2ab4d3eb80d16eb55c19ea661
              to    blob ae2f13a80be0345c2a7dfedbb4cb50b3eb248057
dangling blob 90637871b9c8bf729a45361c7d589dfd8ab76d14
missing blob ae2f13a80be0345c2a7dfedbb4cb50b3eb248057
dangling blob 6e91defb49e3ccbf2cf7950c50a42b6cd5ee51fa

Explanation
  1. Checking Object Directories
    • Broken Link from tree to blob
    • Dangling Blob
    • Missing Blob
    • Dangling Blob

Remediation

OS Commands

Rename hidden .git folder

Please use Microsoft Explorer or MS DOS to rename the hidden .git folder.

Git Commands

Outline

  1. Initialize Repository
  2. Git Pull

Initialize repository

git init

Command

git init

echo "# Set" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/DanielAdeniji/Set.git
git push -u origin master

Output
Output – Image

gitInit.01.20191126.0406AM -v2.PNG

Output – Text

>gitInit

>echo "#Set"  1>>README.md

>git init
Initialized empty Git repository in C:/temp/Set/.git/

>git add README.md

>git commit -m "first commit"
[master (root-commit) e13aa4e] first commit
 1 file changed, 2 insertions(+)
 create mode 100644 README.md

>git remote add origin https://github.com/DanielAdeniji/Set.git

>git push -u origin master
To https://github.com/DanielAdeniji/Set.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/DanielAdeniji/Set.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Explanation
Command Breakdown
  1. Issued git init command
    • git init
      Initialized empty Git repository in C:/tmp/Set/.git/
  2. Issued git add command
    • git add README.md
  3. issued git commit command
    • git commit -m “first commit”
  4. Set URL for Git Remote Repository
  5. Push local folder to Git Remote Repository
    • git push -u origin master
      • git push -u origin master
Command Breakdown

>git push -u origin master
To https://github.com/DanielAdeniji/Set.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/DanielAdeniji/Set.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Command Breakdown – Explanation
  1. ! [rejected] master -> master (fetch first)
  2. error: failed to push some refs to https://github.com/DanielAdeniji/Set.git’
  3. Hints
    • Updates were rejected because the remote contains work that you do
      not have locally.
    • This is usually caused by another repository pushing to the same ref.
    • You may want to first integrate the remote changes before pushing again.
    • See the ‘Note about fast-forwards’ in ‘git push –help’ for details.

Pull repository

git pull

Outline
  1. git pull
  2. git pull –rebase
    • Git Task
      • Untracked files identified
    • Your Task
      • Manually rename or move untracked files
git pull ( No argument )
Command

git pull

Output
Output – Image

gitPull.01.20191126.0409AM.PNG

Output – Text
>git pull
warning: no common commits
remote: Enumerating objects: 7, done.
remote: Total 7 (delta 0), reused 0 (delta 0), pack-reused 7
Unpacking objects: 100% (7/7), done.
From https://github.com/DanielAdeniji/Set
* [new branch] master -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

git pull  

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/ master

git pull – Option ( –rebase ) [ Try -01 ]
Command

git pull --rebase

Output
Output – Image

gitPull.rebase.01.20191126.0416AM.PNG

Output – Text

>git pull --rebase
error: The following untracked working tree files would be overwritten by checkout:
        SetProcessing.sql
        Set.sql
Please move or remove them before you switch branches.
Aborting
fatal: Could not detach HEAD
First, rewinding head to replay your work on top of it...

>

Explanation
  1. Identified untracked working tree files hat would be overwritten
    • error: The following untracked working tree files would be overwritten by checkout:
  2. Move or rename Untracked files
    • Please move or remove them before you switch branches. Aborting
Move or Rename Untracked Files
  1. Please use OS Tools to move or rename untracked files
    • SetProcessing.sql
    • Set.sql
git pull – Option ( –rebase ) [ Try – 02 ]
Command

git pull --rebase

Output
Output – Image

gitPull.rebase.02.20191126.0425AM.doctored.02.png

Output – Text
>git pull --rebase
First, rewinding head to replay your work on top of it...
Applying: first commit
.git/rebase-apply/patch:7: trailing whitespace.
"# Set"
.git/rebase-apply/patch:8: trailing whitespace.
"# Set"
warning: 2 lines add whitespace errors.
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging README.md
CONFLICT (add/add): Merge conflict in README.md
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch' to see the failed patch
Patch failed at 0001 first commit
Resolve all conflicts manually, mark them as resolved with
"git add/rm ", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

>

Explanation
  1. CONFLICT (add/add): Merge conflict in README.md error: Failed to merge in the changes.
    • Hints
      • hint: Use ‘git am –show-current-patch’ to see the failed patch
  2. Patch Failed
    • Patch failed at 0001 first commit Resolve all conflicts manually, mark them as resolved with
  3. Resolve all conflicts manually, mark them as resolved with “git add/rm <conflicted_files>”, then run “git rebase –continue”.
  4. Choices
    • You can instead skip this commit: run “git rebase –skip”.
    • To abort and get back to the state before “git rebase”, run “git rebase –abort”.
Move or Rename Untracked Files
  1. Please use OS Tools to move or rename untracked files
    • Files
      • README.md
git pull – Option ( –rebase ) [ Try – 03 ]
Command

git pull --rebase

Output

— Good —-

 

 

References

  1. Git
    • git-fsck

Summary

Our summary this time is a bit untidy.

BTW, here is our error :-

>git push Enumerating objects: 25, done. Counting objects: 100% (25/25), done. Delta compression using up to 4 threads Compressing objects: 100% (15/15), done. fatal: unable to read ae2f13a80be0345c2a7dfedbb4cb50b3eb248057

 

If you experience pains trying to pushing changes into a remote repository, please do the following :-

  1. Make a backup of your targeted local source code folders
  2. rename the hidden .git folder
  3. Perform git init to create a new hidden .git folder
  4. Continually run “git pull –rebase” until conflicts go away
    • Move or Rename flagged files
    • Flagged files indicates conflicts between local and remote repository

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s