My gitignor file did not stop push to GitHub files - firebase-realtime-database

I learn git and Github and now I added this rule
# misc
.env.production
.env.development
.env
But when I pushad to GitHub this gitignore file and both .env.development and prod. was pushed also very annoying I have to delete Firebase app I think.
What did I do wrong?

If a file is already tracked in a git repository, .gitignore has no effect.
With that said, there is no need to hide Firebase Api keys. source

Related

Rails app turned into HTML on GitHub as I forgot to gitignore

I added SimpleCov and forgot to .gitignore 'coverage' and now my Rails app has accidentally turned into a HTML app on GitHub. This is where my app lives: https://github.com/GeekG1rl/lemon
I tried to add 'coverage' to my .gitignore afterwards and push again but it hasn't updated in my repo (probably because the file is still there).
My assumption is that the directory has already been built but if I delete it, then push again (with 'coverage' in .gitignore), then it will build locally only when being run? If that breaks more things though, I won’t know how to undo that so I'm asking for help before completely breaking it.
I've been coding for three months so please don't be mean if this turns out to be a stupid question ;)
git rm -rf coverage
git commit -m "Remove coverage folder"
git push origin master
.gitignore only covers newly added files and directories, you must manually remove any existing files or directories when you add them to .gitignore.

How to set up a new workstation after adding .gitignore to the repo

I have a deployed rails website, and have a gitignore file in place. If I pull the app to a new computer or workstation, none of the gitignore files will be there since they are being igrnored. How do I correctly set up a new workstation? Do I just copy the files from another location and place them in the correct folders on the new workstation?
What some like to do, including myself, is to add example configuraton to the repo. For instance, you'd add database.yml to the gitignore so that nobody commits their personal passwords and then create a database.example.yml file that contains an example of how to set up database.yml
If those files you specified in the .gitignore are an essential part of your website configuration, they should be in the repository and not ignored.
You have several options:
Ignore files for everyone cloning the project
This is done using the file .gitignore in any folder of your git repository (people usually use one .gitignore at the root folder of the repository). The "ignore-behaviour" will be transmitted to everyone cloning or pulling the repository if you run git add .gitignore, commit and push.
Ignore files only for you, and only in this repository
This is done by using the same syntax as in the .gitignore, but in the file .git/info/exclude. The "ignore-behaviour" won't be transmitted to anyone, and only applies to you and to this specific repository.
Ignore files only for you, for all of your repositories
You can do this by defining a user .gitignore with
git config --global core.excludesfile ~/.gitignore.
Ignore files for all users on this computer, and for all of the repositories
You can do this with a system-wide .gitignore: sudo git config --system core.excludesfile /etc/gitignore
I personally intensively use 1 and 2 (the file .git/info/exclude can really be useful sometimes), but never the 3 and 4.

Handling database files in projects

Within my organisation we use a continuous integration system for deploying Ruby on Rails projects. The normal process for deploying a project is to set it up, enter the database credentials in config/database.yml and then run git update-index --assume-unchanged config/database.yml so local database settings won't be pushed to the server.
Recently switching between branches has been giving us error: Entry 'config/database.yml' not uptodate. Cannot merge. even when the -f / --force parameter is given branch changing will fail.
Does anyone have an idea why this isn't working or a better solution of handling it?
One solution is to add config/database.yml (And any other configuration files that differ between environments) to the .gitignore file.
You'll then need to remove the file from the git repository (Details Here) and manually create it on each environment.

Accidentally created a git submodule

So I was developing a API Client gem, which was working great, had it's own github repository and my team lead decided that he wanted me to move this client api into the api repository itself. So I copied the files over into it's own directory, removed the .git directory from the client's directory, and merged it into master. Worked great.
However, now when I try to create a branch off of master, the directory shows up a submodule on github, and isn't tracked in my local git. There is no .gitmodules folder, and no mention of submodules whatsoever. I can't create a new branch because it says that there are untracked files that will get overwritten (all the files in my client gem directory) but as far as I can tell there's no way for me to start tracking these files. I can access the directory just fine, but as soon as I modify a file, the change doesn't show up in the api projects git.
What do I do?
If there is no .git folder or file in that subfolder, all you need to do is git rm --cached [folder] followed by git add [folder]/*
Running git rm --cached --ignore-unmatch client then allowed me to git add client/

Starting over with Git

I decided to learn how to use Version Control over Christmas break, so I downloaded Git, opened a GitHub account and started reading the online tutorial linked to from the GitHub website. When I got to this part http://progit.org/book/ch2-2.html I got stuck because I wasn't sure how to add files. For instance, I tried
git add C:/Finish.txt
And it said
Fatal: 'C:/Finish.txt' is outside repository
I was confused until I remember that a long time ago I had tried teaching myself Ruby on Rails and played around with Git back then. It never really went anywhere, but there's all this residual stuff floating around my system and I don't know how to change it. For instance, my Untracked files (which should be empty) are rails_projects/ and sample/.
How can I just erase all the old stuff and start over?
You should make a folder for your repository, move Finish.txt to that repository, then do git add.
For example:
# here you create C:\myrepo
cd C:\myrepo
git init .
# here you edit C:\myrepo\Finish.txt
git add Finish.txt
git commit -m "Added Finish.txt"
Start a new repository, e.g.
c:
md c:\newrepo
cd c:\newrepo
git init .
copy \Finish.txt .
git add Finish.txt
git commit -m "started over"
I strongly recommend against adding anything to C:\, let alone putting a git repo there. Unless of course you want to accidentally add all of your system disk to git :)
I can also heartily recommend using TortoiseGit which has some excellent explorer integration.
Delete any .git folder that you find in your drive.
To create a repo go to a folder that you want the repo in ( and not just randomly), do:
git init
Then proceed... Add only files that you put within this repo and not randomly from some location.
It would be very unusual to have the root directory of your hard drive be a git repository. That's probably why it's giving you the error.
git repositories are typically in a subdirectory and that subdirectory is typically a project.
To initialize a subdirectory as a git repository, you'd do:
git init (directory)
Then you'd add your files and commit.

Resources