0

I had a local directory structure on my machine thus:

c:\myprojects\project1\

and

c:\myprojects\project2\

Both directories had multiple files within themselves respectively.

On github, I created a repository named myprojects under root with username, say, Tryer. So, if I navigate to https://github.com/Tryer?tab=repositories, I am able to see just 1 repository of mine named myprojects. So far, so good.

Then, I issued the following commands to replicate the local directory structure on github.

Navigate to c:\myprojects\ on my local machine. Open command prompt.
git init
git add c:\myprojects\project1
git commit -m "firstcommit"
git branch -M master
git remote add origin https://github.com/Tryer/myprojects.git
git push -u origin master

This then replicated the c:\myprojects\project1\ folder online. Then, for c:\myprojects\project2\, I did:

git add c:\myprojects\project2
git commit -m "project2commit"
git branch -M master
git push -u origin master

Now, I wanted to completely remove any online references to c:\myprojects\project2 since there was a bug in the code. I wanted to maintain the local directory where I would continue work on project2 and upload it to github only after fixing the bug. project1 is fine and should remain online.

To do this, I issued:

git rm -r --cached c:\myprojects\project2
git commit -m "Removed buggy project2"
git push origin master

Now, while this did "remove" project2 in that when I navigate to https://github.com/Tryer/myprojects, I only see project1 listed, nevertheless, next to project1, there is a link to a page with text Removed buggy project2 (the most recent descriptive name of the commit) which tells me what this commit was about. Here, it provides in full detail what exactly changed in project2 with a link to a diff between the at-present nonexistent files under project2 and what they were in the previous buggy commit.

So, project2 still continues to be "available" online, occupying space, etc.

Is there a way that even this data is removed from online github?

Tryer
  • 3,580
  • 1
  • 26
  • 49
  • Check these topics - https://stackoverflow.com/questions/872565/remove-sensitive-files-and-their-commits-from-git-history, https://stackoverflow.com/questions/307828/how-do-you-fix-a-bad-merge-and-replay-your-good-commits-onto-a-fixed-merge, https://stackoverflow.com/questions/2004024/how-to-permanently-delete-a-file-stored-in-git. Overall, if `project2` does not contain some sensitive/secret information, just don't care about that. Usually, when file is removed from git anyway git keeps it in the history - because what if you'd like to go back in time with commits? – kosist Oct 05 '20 at 11:33
  • @kosist All your links seem to suggest something extremely complicated. While you suggest not to care, somehow I don't like useless and buggy code lying online in one form or another. I personally feel something this straightforward should be doable. But perhaps there are other reasons why this is not featured except via complicated operations. – Tryer Oct 05 '20 at 11:42
  • Task of git - is to keep and maintain history of files. So if you modify/remove files from git repository, it will keep their previous states in the history. Because otherwise there would not be a chance to go back to some specific past commit. – kosist Oct 05 '20 at 11:45
  • If you want to remove commits, you can use the dangerous `git reset` command. Have you explored that option? – mnestorov Oct 05 '20 at 17:33

0 Answers0