heondo / reddit_pl

reddit pipeline practice
0 stars 0 forks source link

Where to put .gitignore file to exclude creds, other files #1

Open Niarfe opened 5 years ago

Niarfe commented 5 years ago

i tried to create a .gitignore text file. So my project is in ~reddit_pl/* Put my .gitignore.txt in reddit_pl/.git/ .gitignore.txt looks like rootkey.csv which is in reddit_pl/rootkey.csv. should it be ~/coding/reddit_pl/rootkey.csv ? Misplaced the file?

Niarfe commented 5 years ago

Hi Heondo, the way the .gitignore usually works is that it covers any files listed. It covers paths to files within the repo only obviously, and relative to the location of the .gitignore.

Also, beware that if you already checked in a file, .gitignore may not exclude it without you removing it first from git. But here's some examples...

very standard .gitignore at root of repo.

This usually covers any fluff you don't want, like those pesky *.pyc files that generate when you run python sometimes. So...

  1. Create .gitignore at root of repo
  2. Any files can be called out directly by name, so *.pyc would mean exclude any pyc files. This covers any pyc files in root directory next to .gitignore. If you want to cover ANY pyc files recursively in the repo, the notation is **/*.pyc meaning, any pyc in this , or recursive directory. Similarly for any other type of extension.
  3. You can cover one off files or directories, like .pycharm/ or .vscode etc.

Most repos have a .gitignore with the basics

  1. Exclude pyc
  2. exclude any IDE folders, .pycharm, .vscode
  3. other stuff that gets generated automatically like __pycache__. There is a github repo with good starters, this is the python one... https://github.com/github/gitignore/blob/master/Python.gitignore

Also...for credentials... If you want to use a folder for creds, say for example config/myawscreds is a file, but you don't want to check that in, you would do this....

  1. create the config directory.
  2. create a file condig/myawscreds.example and put in the format... i.e.
    [default]
    aws_secret_key=
    aws_key=
  3. add a config/.gitignore and in it put myawscreds
  4. Step 3 has the effect of allowing you to have a checked in example that you can fill in when you check out a fresh copy of your repo, just copy it and put the creds in it. If you rename it myawscreds your other files can use that, AND the .gitignore guards you against accidentally checking it in. The example and .gitignore files have to be checked in, but after that you should be fine.
heondo commented 5 years ago

FINALLY I got the reddit credentials into the config folder, made it so my scripts read from the text file to run. My scripts are definitely a structural mess, but well for now I just needed my reddit password and username away from the git repo. And, it's technically working now. Time to work on the lambdas functionality now....yeah. Once I figure out all of the, "clerical" work surrounding my scripts, I should probably rewrite it so that it is...just written well, thank you for this documentation it was basically all i needed