0

First off, I've looked everywhere for an answer and couldn't find a solution.

I made a commit and pushed a lot of files and directories to my github pages that weren't supposed to be pushed. When I did "git status" I see a lot of untracked directories and files. When I did "git clean -df" it only removed files from the directory that I needed to have on my github pages. Right now, I'm stuck with all these untracked files and a git repo full of unwanted directories. Untracked Files

MarocCoder
  • 11
  • 4
  • git clean -xf or git clean -df might help you. Otherwise, manual deletion is always possible through file system utilities. – Tanveer Badar Aug 01 '17 at 14:48
  • "-x" is probably what you're after, along with "-n" to test it beforehand: https://git-scm.com/docs/git-clean – Chris Aug 01 '17 at 14:48
  • I've tried -xf and -df and when I do git status, all these untracked files are still showing up. – MarocCoder Aug 01 '17 at 14:56
  • 2
    `git clean` works from the current directory. `git status` looks at the entire repository. You are in a sub-directory of your repository, which is why all those other files are named `../something`. Go up to the top level before running `git clean`. – torek Aug 01 '17 at 15:15
  • Possible duplicate of [How can I remove a commit on GitHub?](https://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github) – phd Aug 01 '17 at 18:10

1 Answers1

0

You can try to remove all files that should be ignored using

git clean -Xf ; git clean -xf

Remove the files that are not supposed to be pushed manually using

git rm file1 file2 ...

Then manually add all files that should be tracked using

git add file3 file4

If there were confidential information inside the last commit you should use

git commit -a --amend 
git push -f origin gh-pages

to "update" the last commit you've made and to overwrite it on your GitHub site as well.

Otherwise, you would just commit this and push it just as a normal commit

git commit -a
git push origin gh-pages

Like this you should be able to remove what you didn't want to be online and to push out what should go there.

0xpentix
  • 732
  • 9
  • 22