Is it good practice to add .git folder to Github? - django

After i entered git init I have directory D:myproject\.git
Is it good to add .git folder it in Github or should i add it in .gitignore?

You should not worry about .git folder. It contains git internals and all information in your repository like commits, branches and blobs. So .git is a repository itself and is handled automatically.

If you are in the root directory of your app and you do git init command what happens is that the command says initialize this directory and everything below it as a git repository. And it will set up a local repository for you on your machine.
Local repository on your machine allows git to track version changes in our files. Once we are happy with all those changes and our files then we push them to a remote repository on GitHub.
And you don't have to add your .git folder in .gitignore file.

Related

Git ignores all files

My gitignore file looks straighforward:
env/
.idea
*.pyc
__pycache__
*.env
/environment
db.sqlite3
*.log
When I do git add . from my root project folder and then check status - I see there is no files tracked.
When I do git status --ignored, I see that all folders are ignored:
.flake8
.gitignore
.idea/
Procfile
env/
requirements.txt
runtime.txt
src/
So it somehow ignores all the folders and files.
I tried to comment everything in gitignore - and the result is the same.
I tried to reinitialize the git by:
rm -rf .git
git init
And the result is the same.
How can I add my files, without git add --force?
I want files that are added in gitignore to be ignored, but still to commit other files.
As in the comments: it seems that venv or virtualenv created a global .gitignore (in /Users/admin/.gitignore) whose second line read *, ignoring all files.
It's not clear what caused this venv entry to be created in /Users/admin in the first place, so finding out if anything depends on it remains to be done, but in the meantime, any virtual environment data in the home directory here should be moved or removed, so that the global .gitignore isn't there any more.

Docker files to be ignored on .gitignore

I'm new to docker. I've finalized dockerizing a Django projet of mine. What files and/or folders should I add to my .gitginore before pushing the changes to the project? Or no files should be added? I'm not talking about my .dockerignore file.
You should include any files that don't need to be in the final distribution or will be built when the container is built. Depending on your build process, this might include what is compiled for static assets (JS/CSS), Python packages downloaded by pip in venv as the build process might download again for each new build, any keys/secrets/passwords should not be committed to the .git repo as well, any caches or temporary files.
With docker builds, I prefer to keep them isolated so that only code is copied and then the rest is built by the docker build process. So packages are installed by pip and the config/keys/passwords are passed into the docker container as environment variables. Also, I typically put .git into the .dockerignore so the entire git repository isn't copied into the docker image.
You might find these two links helpful:
Docker Django
Django .gitignore

What is node_modules directory in ember

What is the usage of node_modules directory in ember?
I could see this directory created accross my ember application. When does it get created and what is the significance?
What harm if i delete this directory?
It's a directory for npm/yarn. It's created by running npm install or yarn. Theese commands install all dependecies specified in the package.json file into the node_modules directory. You need them to run any ember commands. If you delete the folder you can recreate it with npm install/yarn. It's not checked into source control.

How to push a git submodule to AWS Elastic Beanstalk?

I have a repo named ld with a submodule named ldapp, which is a Django project. I want to push the Django project ldapp to elastic beanstalk, but I get the warning following warning when running eb init:
Warning: Your directory has not been initialized as a Git repository.
To create a local Git repository, run "git init" and then re-run the
"eb init" command.
If I continue on and run eb push I get:
git: 'aws.push' is not a git command. See 'git --help'. Cannot run
aws.push for local repository HEAD:
The way git structures submodules is it actually has the .git of the submodule be a file, not a directory. The following is the contents of the file ldapp/.git:
gitdir: ../.git/modules/ldapp
This file tells git to retrieve ldapp's versions from ld's .git directory. Since the .git versioning of ldapp is not present within ldapp itself (but rather within ld's .git), running eb init and eb push fail. How do I fix this?
I don't think you can. I had to git clone the submodule to get back a standalone Git repository.

How to import a Django app from Git into a project

I want to include a Django app into the project I'm working on. The app is hosted on Github ( https://github.com/lmorchard/django-badger ). As well as the app's directory containing the goodies, there are some files in the root - README, LICENCE, TODO and setup.py. If I clone the app into my project's root directory, the app folder will be in the correct place, but those root files will be in my project's root. How can I add the app while still tracking the upstream code in Github?
I had a similar issue where I was working on two independent projects where both were in a repo, and one of them used the other as an app:
Create a virtualenv and install all dependencies for both projects. I usually like to have a virtualenv for each project/repo but in this case you need one env which can execute Python from both repos.
Clone both repos to independent location. Do not clone the depending app inside the other project. Your file-structure then might look like this (assuming Django 1.3 project layout):
project/
manage.py
project/
__init__.py
settings.py
...
...
app/
README
...
app/
__init__.py
models.py
...
And final step is to create a symlink (or shortcut on Windows) from the app directory which has __init__.py in it to the project path.
$ ln -s /abs/path/to/app/app /abs/path/to/project/
Now you can use the virtualenv to run the project!
The final result is that you have two independent repos however one of projects is using the other project without directly copying the code, hence allowing you to maintain two repos.
U can install it by running
python setup.py
or through pip
sudo pip install -e git+https://github.com/lmorchard/django-badger#egg=django-badger
Clone the repository from github using git://github.com/lmorchard/django-badger.git. Then open the cloned folder in terminal. Install the app using the command sudo python setup.py install. This will work good. If you want to have the app included in your project, create a folder named badger(or anything you wish) and copy the installed app from dist-packages to created folder.