About this question
Something wrong is going on with one of the files in my local git repository. When I'm trying to change the branch it says:
Unlink of file 'templates/media/container.html' failed. Should I try again? (y/n)What does it mean?
Something wrong is going on with one of the files in my local git repository. When I'm trying to change the branch it says:
Unlink of file 'templates/media/container.html' failed. Should I try again? (y/n)What does it mean?
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask DevOps Expert
Answered on Jun 8, 2021
Getting message of git unlink of file failed means that another program is using the same file, which is preventing git from "moving" the file into or out of the working directory when you are attempting to change branches.
In this sort of scenario, try closing the file in any applications that might have used it. If that does not work, completely exit any applications which may have opened the file
Ranjana Admin JanBask Expert Latest answer
Answered on Feb 5, 2025
If you’re seeing the error “Unlink of file failed” in Git, it means Git is trying to remove or modify a file, but something is preventing it. This is usually due to file permissions, background processes, or antivirus software locking the file.
Should You Try Again?
Yes, but first, check for the possible causes and apply the right fix before retrying.
Common Causes and Fixes
1. File in Use by Another Program
2. Insufficient Permissions
Try running the command with elevated permissions:
sudo git checkout -- file-name # On macOS/Linux git checkout -- file-name # Run Git Bash as administrator on Windows3. Antivirus or Security Software Blocking Git
4. Remove Write Protection
Manually change file permissions:
chmod +w file-name # On macOS/Linux attrib -r file-name # On WindowsForce Git to Reset the File
If nothing works, try:
git reset --hard
git clean -fd Warning: This will discard uncommitted changes!
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Most-read guides across JanBask
Common DevOps interview questions, answered
Guides, tips and career advice on DevOps from JanBask experts.
DevOps How to Become a DevOps Engineers: Learning Path, Critical skills & More
Looking for answer to how to become a DevOps engineer in 2025? Here is the detailed article about DevOps career path, DevOps…
DevOps Top 50+ Jenkins Interview Questions And Answers For 2025
Here are the Top 50 Jenkins interview questions frequently asked in top MNCs which will help you land an ideal job! These…
DevOps Best 37 DevOps Tools To Learn And Master In 2025: Docker, Git & More
Want to know what are Devops tools and their uses? Or looking for the best DevOps list for automation, monitoring, & development?…
DevOps DevOps Engineer Job Description: Roles and Responsibilities [2025 Updated]
Discover the essential roles and responsibilities of a DevOps Engineer by exploring the detailed DevOps job description, and…