Git rename but GitHub shows it as added file and deleted file #43177
Replies: 13 comments 23 replies
-
|
try using the git mv command to explicitly rename the file, rather than simply moving it in the file system. This will help Git track the file's history more accurately. |
Beta Was this translation helpful? Give feedback.
-
|
Git is very good about detecting when files are renamed, and as you described it did for you. I assume this is simply a limitation of the GitHub UI. |
Beta Was this translation helpful? Give feedback.
-
|
Just curious, were you using Windows when you did this? Git on Windows can automatically convert line endings depending on settings, so perhaps the commit tracks different line endings than the original file had. |
Beta Was this translation helpful? Give feedback.
-
|
Hi
|
Beta Was this translation helpful? Give feedback.
-
|
Facing the same issue. |
Beta Was this translation helpful? Give feedback.
-
|
Please fix this issue. This heavily impacts productivity of code review whenever it happen. |
Beta Was this translation helpful? Give feedback.
-
|
Impacted. |
Beta Was this translation helpful? Give feedback.
-
|
Same here. Git can recognize renaming, but github ui showing the same file as deleted/added |
Beta Was this translation helpful? Give feedback.
-
|
We are also hit by this- really what the .... is going on. git mv file file2
git commit -am "rename file to file2"
echo "changes to file 2" >> file2
git commit -am "Changes to file2"
git pushThis certainly was not an issue on gitlab. The kicker is if you look at the commit where you rename the file you actually see that it is renamed without changes, looking at the commit where I did the changes to the file for itself also shows this correctly - however in the overview with both commits it suddently is deleted and then created... @spenserblack any comment on that? |
Beta Was this translation helpful? Give feedback.
-
|
This also confused me for a while and then I noticed. git shows correctly but github shows files added and deleted |
Beta Was this translation helpful? Give feedback.
-
|
I ran into the same issue. My PR has two commits: one with file renames only, and a second with modifications to the renamed files. If you view the changes by commit, the diffs display correctly, but in the “Files changed” tab the files appear as deleted and newly created with different names. It makes code reviews significantly harder. |
Beta Was this translation helpful? Give feedback.
-
|
Same here, I moved a file from one directory to another and committed the change. Both my local Git diff and GitHub’s UI correctly showed it as a rename. However, after I made a second commit with a bunch of changes to that same file, my local Git still recognizes it as a rename, but GitHub’s PR view now shows it as a Deleted and Created file instead of a renamed file with modifications. Please consider improving rename detection so GitHub can still track renames even when the file is significantly modified. |
Beta Was this translation helpful? Give feedback.
-
|
Have the same issue but shell git 2.39.5 looks like a git bug :-( The solution is to split move/rename and content change into several commits ;-) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Bug
Body
Hi,
The issue in detail:
test_ceph_s3.jswas recognized now as renamedtest_ceph_s3.jsas added and deleted file.Note: this was not the only file that I moved and renamed in this PR, all the other file was recognized as renamed in Git and also in GitHub.
I read here that I should have used git mv (which as you can read above I didn't use...), and maybe it would fix it, but I'm not sure it would work since Git recognized the change of the file as renamed.
Thanks,
Shira
Beta Was this translation helpful? Give feedback.
All reactions