0

I have been working on a git project with a remote on Github. It contains several submodules.

When creating a submodule, my git client (Sourcetree) created a folder with an invisible character, which has been wreaking havoc. The folder has been pushed to Github, and I can't find a way to revert.

The submodule folder looks like it's named "cours-divers", but is displayed in Sourcetree as "cours020-divers", and shown as "cours?-divers" in Terminal.

Also, Sourcetree isn't able anymore to display the list of submodules.

What I attempted, after reading through related threads:

  • Simply deleting it. Unfortunately, Git cannot properly track this file so it doesn't get deleted. Error message: fatal: pathspec 'cours020-divers' did not match any files
  • Doing git reset --hard [revision]. This works fine for my local version, but the remote (Github) requires me to pull the changes. I would need to be able to reset the remote as well.
  • Doing git checkout [revision] . Seems to bring things back to normal, but the problematic file is still polluting the project.

Is there a way to "go back in time" in such a way that Git effectively forgets about that file, both locally and on the remote?

Steve
  • 1,553
  • 2
  • 20
  • 29
Manu
  • 849
  • 1
  • 8
  • 20
  • Possible duplicate of [Completely remove file from all Git repository commit history](http://stackoverflow.com/questions/307828/completely-remove-file-from-all-git-repository-commit-history) – Greg Burghardt Sep 13 '16 at 20:02
  • Regarding the possible duplicate above – this method wouldn't work in my case, because of the filename issue. You cannot `git rm` a file if git cannot handle the characters in the filename. – Manu Sep 13 '16 at 20:40
  • Does this question shed any light on the issue? http://stackoverflow.com/questions/31846045/remove-characters-in-a-unix-file I wonder if you can remove the invisible chars and do a `git add --all` to stage the renamed file for a commit. – Greg Burghardt Sep 13 '16 at 23:11
  • Thanks for the link! However, in that question, the characters occur *inside* the text file - in my case, it was in the actual filename. Anyway, I got rid of it... – Manu Sep 14 '16 at 00:48

1 Answers1

0

Finally, after some more trial and error, I found that this thread provides the answer: Resetting remote to a certain commit

git reset --hard <commit-hash>
git push -f origin master

Doing this does effectively push the project back in time, and gets rid of any reference of the offending file.

Community
  • 1
  • 1
Manu
  • 849
  • 1
  • 8
  • 20