How do you create a gitignore file in pycharm? (windows) - python

What i could find relating to git settings on pycharm

In the Project tool window, select one or more files you wish to be ignored, then right click on the selection, then Git > Add to .gitignore > Add to .gitignore. If the .gitignore file does not exist, you will be asked for confirmation to create it.

First install the ignore plugin:
Then right-click the project root directory: New > .ignore File > .gitignore
If you want to simply create a .gitignore file in PyCharm, go to the PyCharm terminal and type: echo "" > .gitignore. Then open the .gitignore file, delete the double quotes, and update however you'd like.

Create a file with name .gitignore in the root directory of your project. Add all the files which you want git to ignore while versioning, in it.

Related

git ignore not ignoring a file when using GCloud's gcloudignore

I have a rule to ignore secret.py (production.py in my case) and once I added .gcloudignore, github stopped following that rule...
Is there some sort of a rule overriding between gitignore and gcloudignore that I am not aware of?
my-project/
.git
.gitignore
my-project/
.gcloudignore
settings/
base.py
local.py
production.py
my .gitignore:
my-project/my-project/settings/production.py
my-project/my-project/settings/local.py
my .gcloudignore:
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore
*.sqlite3
settings/local.py
End result is that the 'local.py' is NOT pushed to google cloud NOR github.
However, 'production.py' IS pushed to github AND gcloud.
If you had previously (perhaps accidentally) submitted a change to git that included my-project/my-project/settings/production.py, then it will remain a part of the repository even if it is subsequently added to .gitignore.
Assuming you are at the root of your project, you can use
$ git log my-project/my-project/settings/production.py
to see its git history. If it is present in your repo, you can do
$ git rm --cached my-project/my-project/settings/production.py
to remove it from the repo, but keep it in your local (working) environment.
Looks like you are enforcing to ignore the rules applied before.
Though make sure that the cloudignore is enable via
gcloud config set gcloudignore/enabled true
And make sure to place .gcloudignore - > in the root of your project / basically where you .git .gitignore reside.

PyCharm - how to use a folder that is not in the base directory

I want to use a folder that is not in the base directory of my django project without adding it in to the base directory.
Open File > settings menu and then goto project: foo > Project Structure and press Add Content Root, then select destination directory.
and after folder added in list, right click on the folder and set as source, in last step press OK...

How to add all catalog using GIT without .pyc file?

How to add all catalog using GIT witout .pyc file?
git add catalog_name
git commit -m "Update"
git push
What add and where?
use .gitignore file. add '*.pyc' to it.
The file is located in root directory of your repo i.e. where you did git init
Here is a good .gitignore file for python projects, containing common extension to ignore in git commit.
https://github.com/github/gitignore/blob/master/Python.gitignore

What do I specify for "Rope project root folder: . " with python files and RopeVim plugin?

I've installed the plugin RopeVim (using Pathogen) and it seems to be working.
Now when I call :RopeGoToDefinition with my vim cursor (in command mode) on a function I'd like to see the definition of...I get:
Rope project root folder: .
displayed in the status line of my vim (fwiw, I'm using MacVim).
What is the proper folder to specify here?
My project folder structure has a root folder, and various subdirs. I can't even tell if I should be specifying a system filepath or a python-style module.
See https://github.com/python-rope/rope/blob/master/docs/overview.rst#ropeproject-folder and the Getting Started section of https://github.com/python-rope/rope/blob/master/README.rst
You can stick it anywhere, but you probably want to use the root directory of your project. Note how the prompt defaults to ., the current directory. If your file is in the root directory, you can just hit Enter to accept that default. Otherwise, try something like ../.. or /path/to/root.

Ignore .pyc files in git repository

How can I ignore .pyc files in git?
If I put it in .gitignore it doesn't work. I need them to be untracked and not checked for commits.
You should add a line with:
*.pyc
to the .gitignore file in the root folder of your git repository tree right after repository initialization.
As ralphtheninja said, if you forgot to to do it beforehand, if you just add the line to the .gitignore file, all previously committed .pyc files will still be tracked, so you'll need to remove them from the repository.
If you are on a Linux system (or "parents&sons" like a MacOSX), you can quickly do it with just this one line command that you need to execute from the root of the repository:
find . -name "*.pyc" -exec git rm -f "{}" \;
This just means:
starting from the directory i'm currently in, find all files whose
name ends with extension .pyc, and pass file name to the command git rm -f
After *.pyc files deletion from git as tracked files, commit this change to the repository, and then you can finally add the *.pyc line to the .gitignore file.
(adapted from http://yuji.wordpress.com/2010/10/29/git-remove-all-pyc/)
You have probably added them to the repository before putting *.pyc in .gitignore.
First remove them from the repository.
Put it in .gitignore. But from the gitignore(5) man page:
· If the pattern does not contain a slash /, git treats it as a shell
glob pattern and checks for a match against the pathname relative
to the location of the .gitignore file (relative to the toplevel of
the work tree if not from a .gitignore file).
· Otherwise, git treats the pattern as a shell glob suitable for
consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in
the pattern will not match a / in the pathname. For example,
"Documentation/*.html" matches "Documentation/git.html" but not
"Documentation/ppc/ppc.html" or
"tools/perf/Documentation/perf.html".
So, either specify the full path to the appropriate *.pyc entry, or put it in a .gitignore file in any of the directories leading from the repository root (inclusive).
i try to use the sentence of a prior post and don't work recursively, then read some help and get this line:
find . -name "*.pyc" -exec git rm -f "{}" \;
p.d. is necessary to add *.pyc in .gitignore file to maintain git clean
echo "*.pyc" >> .gitignore
Enjoy.
If you want to ignore '.pyc' files globally (i.e. if you do not want to add the line to .gitignore file in every git directory), try the following:
$ cat ~/.gitconfig
[core]
excludesFile = ~/.gitignore
$ cat ~/.gitignore
**/*.pyc
[Reference]
https://git-scm.com/docs/gitignore
Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig.
A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
if you have committed in the repo, just
go to the folder /__pycache__,
delete all of them (no worries, they are temporary files and generated repeatedly)
have a new commit, such as 'update gitignore'
you are done! .pyc will not appear again.
Thanks #Enrico for the answer.
Note if you're using virtualenv you will have several more .pyc files within the directory you're currently in, which will be captured by his find command.
For example:
./app.pyc
./lib/python2.7/_weakrefset.pyc
./lib/python2.7/abc.pyc
./lib/python2.7/codecs.pyc
./lib/python2.7/copy_reg.pyc
./lib/python2.7/site-packages/alembic/__init__.pyc
./lib/python2.7/site-packages/alembic/autogenerate/__init__.pyc
./lib/python2.7/site-packages/alembic/autogenerate/api.pyc
I suppose it's harmless to remove all the files, but if you only want to remove the .pyc files in your main directory, then just do
find "*.pyc" -exec git rm -f "{}" \;
This will remove just the app.pyc file from the git repository.
Zachary's answer is correct. The reason that it's likely correct in your case is that gitignore will not work for files that preexist the gitignore (or the repository).

Categories