1

I deleted some files on my default Github.com branch.

I added them back on a new branch and commited the files for code review.

Now when I open a pull request, Github.com says there are no changes to compare.

But the files are on the child branch and no files are on the default/base branch.

How can I "force" delete the files on the default branch and make Git forget they ever existed?

This is a new repo so forgetting about all git history could also solve my problem. That is acting like all files on the default branch are the initial commit.

ViktorMS
  • 1,112
  • 10
  • 25
  • Did you commit the deletion of the files? Please share the commands used and their output. (Use text, not images) – evolutionxbox Jul 03 '23 at 13:45
  • It is almost impossible to make git forget they ever existed, because git is version control which is supposed to track all files that ever existed. Judging from your last sentence, I would just create a new fresh repo to "undo" your issue. That is the easiest way to fix such things. – tomwaitforitmy Jul 03 '23 at 13:48
  • @tomwaitforitmy you can use `git filter-branch` to remove files completely, but it's not easy. https://stackoverflow.com/questions/7430717/git-filter-branch-on-all-branches – evolutionxbox Jul 03 '23 at 13:49
  • @evolutionxbox Yes, and maybe he can do an interactive rebase or whatever. But that's all not easy. That's why I wrote "almost impossible" and "the easiest way to fix". The most important thing is to wrap your head around that git should ideally never forget files, because it is version control. – tomwaitforitmy Jul 03 '23 at 13:57
  • If you properly removed the files from the default branch, git should show the "new" files from the branch in the merge-request. So maybe re-check your history on the default branch. – Jay Jul 03 '23 at 14:27
  • Neither the folder or the files exist on the base branch, but the PR still shows it as "no files have changed" when comparing a new branch to the base – ViktorMS Jul 03 '23 at 14:36

2 Answers2

0

I solved this by duplicating the folder and renaming it.

Then it shows up in code review / pull request instead of no changes to compare.

ViktorMS
  • 1,112
  • 10
  • 25
0

Neither the folder or the files exist on the base branch, but the PR still shows it as "no files have changed" when comparing a new branch to the base.

This is probably because of the current incident with Pull Requests.

You can force the PR to be refreshed with your latest commits in the meantime.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250