'How to revert changes to deleted and then recreated file with same content in git to it's state in origin branch?

How to revert changes to deleted and then recreated file in git branch? I want these changes not to appear in git diff with main branch I've diverged from.

My steps were the following:

  1. diverged from main branch to branch test
  2. deleted file src/patches/axios.patch (not actual name, I'm using patch-package npm package so names are correct in my project for sure)
  3. committed change and pushed to remote
  4. generated new patch for axios with same name in other place (axios.patch)
  5. copied new patch from step 4 to src/patches as axios.patch
  6. committed changes and pushed to remote
  7. now in Github PR page I see same file deleted and same file added enter image description here

I know that I can revert a file to some specific state at some specific commit. In my case it would be main branch state when I've diverged from it ( if file changed in meanwhile )?

I've also checked git diff main on my branch and there are these changes also present, so it's not Github UI glitch:

diff --git a/src/patches/axios.patch b/src/patches/axios.patch
deleted file mode 120000
index fcc8ab7fb..000000000
--- a/src/patches/axios.patch
+++ /dev/null
@@ -1 +0,0 @@
-../../patches/axios.patch
\ No newline at end of file
diff --git a/src/patches/axios.patch b/src/patches/axios.patch
new file mode 100644
index 000000000..fcc8ab7fb
--- /dev/null
+++ b/src/patches/axios.patch
@@ -0,0 +1 @@
+../../patches/axios.patch
\ No newline at end of file
git


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source