0

I have a file called Thinking.py that I add to each of my projects that is my own personal log of what's going on in the project.

I recently created a flask and python template that I'd like to put publicly on GitHub, but I don't want it to include the Thinking.py because that contains my own personal comments.

I added Thinking.py to my .git/info/exclude, but when I uploaded the project to gihub, the Thinking.py file still showed up.

Note that Thinking.py was included in previous commits before I edited .git/info/exclude.

How can I make it so that nothing about Thinking.py is uploaded to GitHub, but all the changes and commits with Thinking.py remain as they are on my computer?

Pro Q
  • 4,391
  • 4
  • 43
  • 92

2 Answers2

2

Git doesn't push files. Git pushes commits. If the file is in some commit, and you push the commit, they get the file. If you don't push that commit, they may already have the file, but they don't get it with that commit you don't push.

If you want to be absolutely sure you never accidentally push any of the commits that do have that file, make sure there are no such commits, by not committing the file. Otherwise, be careful about which commits you push: the moment you push any commit that has that file, they have the file (because they have that commit and that commit has that file).

If you need to remove the file from existing commits, you have to remove the commits themselves too, because no commit can ever be changed, not one bit. Removing them entirely is not easy, but it can be done. You'll probably want new-and-improved commits that you can use in place of the old commits that did have the file. to do that in an automated fashion—doing it by hand is no fun—you will probably want to use git filter-branch, which is a very tricky Git command with a crazy number of options, that can do a whole lot to a repository, or the BFG, a Java tool that does a very limited subset of what git filter-branch does but is much faster and more user-friendly. See the many StackOverflow questions about the BFG.

torek
  • 448,244
  • 59
  • 642
  • 775
0

Is the Thinking.py file also updated by git according to the newest changes? Based upon your question I think that the Thinking.py file in GitHub is simply a result of your previous commits and does not contain the newest changes anyways.

You could try to get rid of the file altogether (Make sure you don't delete your local file accidently):

Remove a file from a Git repository without deleting it from the local filesystem

I hope I could help!

Josip Domazet
  • 2,246
  • 2
  • 14
  • 37