user image

Rakshit
Published in : 2022-03-01

git issue, fatal error: your current branch appears to be broken

General

Something went wrong while I was doing some action with git as given below,

  • I was working with sub-branch
  • Pushed new commits to the remote branch using git command
  • Changed branch to the main - master branch

When I hit command “git checkout master”, my computer gets an unexpected force shut down twice. (I never tried the same more than that). After that, I turned on PC (Running with Windows 7 since last 5+ years) and was observing files under my master branch, it shows all files marked as new files.

If I hit git log command, it shows below error:

> git logfatal: your current branch appears to be broken

Is there any way to restore my branch without deleting it?

Ref: Git

Comments

Gulafsan Shaheen Date : 2022-03-01

Best answers

1

Best answers

1

Once I was facing the same error when I renamed the folder and the hash was broken up, I solved it by cloning the repository to a new directory and replacing updated files. I see only it is the safe way.

Alternatively, you can remove “.git\refs\heads\ ”, it will fix your issue, but before removing backup your new files.
 

 

Thanks.

Rakshit Date : 2022-03-01

Best answers

34

Best answers

34

I cloned the folder to another directory and merged my 30+ files with it. Now it is working fine. It saved me from heart attack.

I'm afraid to remove .git or related folders.

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

Choose default editor from filezilla on Ubuntu
Publish date: 2022-02-28 | Comments: 4

Tag: General

Convert Stored Procedure of Oracle to SQL Server
Publish date: 2022-03-02 | Comments: 1

Tag: General

How do i r etrieve users?
Publish date: 2022-03-04 | Comments: 0

Tag: General

Connecting jupyter notebook with Android studio
Publish date: 2022-03-05 | Comments: 1

Tag: General

Is it possible to git commit files without adding a message or comments?
Publish date: 2022-03-02 | Comments: 2

Tag: General

Password authentication is temporarily disabled as part of a brownout.
Publish date: 2021-07-28 | Comments: 2

Tag: General

Chrome shows cursor everywhere where I click?
Publish date: 2022-03-11 | Comments: 2

Tag: General