Skip to content

Instantly share code, notes, and snippets.

@Tknott95
Created February 4, 2018 21:15
Show Gist options
  • Save Tknott95/f11f9ae2c93d2a19d59e986b802bb95c to your computer and use it in GitHub Desktop.
Save Tknott95/f11f9ae2c93d2a19d59e986b802bb95c to your computer and use it in GitHub Desktop.
Git error: Failed to resolve HEAD as a valid ref.
#TO FIX Git error: Failed to resolve HEAD as a valid ref.
##### cd into repo
$ cd ~/Workspace/MyProject/
##### remove .git recursively (Just do it this way so it restores proper)
$ rm -rf .git
###### Initialize a new repo
$ git init
###### Add remote URL for git via: ssh
$ git remote add origin git@github.com:<YOURGITUSERNAME>/<REPO>.git
EXAMPLE: git remote add origin git@github.com:Tknott95/this_is_a_project.git
###### ADD CHANGES
$ git add .
###### COMMIT CHANGES
$ git commit -m 'Fixed BROKEN HEAD'
###### PUSH UP TO MASTER FINALIZE SYMLINK
$ git push -u origin master
@Tknott95
Copy link
Author

Tknott95 commented Feb 4, 2018

If merge conflicts and you are a savage $ git push -uf origin master (NOT AT YOUR COMPANY LuLZz)

@Tknott95
Copy link
Author

Tknott95 commented Feb 4, 2018

-uf pushes to upstream forcibly.

@GaddMaster
Copy link

Thanks

@ajayvavdiya
Copy link

Thanks

@jjswifty
Copy link

jjswifty commented Oct 3, 2020

Thx

@manuchehr94
Copy link

Thanks a lot.

@Aqoolare
Copy link

Спасибо, брат!

@chineduogada
Copy link

Damn you, bro it deleted all files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment