So if we look at our file system now you can see we have this node_modules and it has all kinds of different files inside of that. So I'm going to create a directory here called node_modules and then I can even add some files to it so I can say inside of this node_modules is going to be one.js and two.js and just for good measure three.js Let's imagine that we have another file or actually that we have a directory. Now that's how you can add a single file. And now if I type get status everything here is good. So I'm going to create a new commit message here so I'll say added gitignore file and deleted git cache. I did want to give that to you in case you ever run into that in the future you'll know what to do. That's a command you can run but if it was working fine for you with the first step then don't worry about it. You shouldn't do that on a regular basis obviously, it's there for a reason but it is helpful in case you run into an error where you've already cache that file and you want to remove it. Now you can see that it shows the elements that were deleted and then the Untracked files. and if you run this then it's going to remove all of the cache changes on your local machine and then it should work for you assuming that everything is spelled correctly. What it does to help with performance is it uses a cache where it tries to keep a brief history of everything that you've done and so you simply can delete that cache and so the command you can run is git rm -r -cached. And what that usually means is either that you misspelled the file name in your git ignore or that you may have in your cache. Now one thing I will say as a caveat is if you run through that entire process and that didn't work so if you see the git ignore file and you see the secret file that's happened to me as well. And now we only have our git ignore files so this is working absolutely perfectly. So if we want to hide our secrets I can just type secrets.yml and then if I save the file close it and then now type git status you're going to see that the secret's file that used to be an untracked file is now gone. gitignore.Īnd anything that we put inside of this file is going to be ignored. And so you see the way it is spelled just. gitignore just like that and I'm going to save it come over here. So I'm going to open up the text editor and then create a new file and the name of it has to be very specific it has to be. And so what we're going to do is we're going to create a git ignore file. So if I quit out of both of these if I quit and type git status you can see that we have an untracked file for secrets and this is exactly what you would expect to see.īut we don't want if we added this to our history and we push this up our secrets would be pushed up to Github and that would be a very bad thing. And so now this is at the root of the application. This is just something where you can imagine this is something that you do not want everyone else in the world to have access to. And this is not my actual AWS secret just FYI. And so if I come here and you can see I just have my file the git directory and then the readme but if I add a new file and I'm just going to call it secrets.yml and I'll put my AWS secret right here. So I'm going to switch over to the terminal and the way we're going to start this is git looks for a very specific file called a git ignore file. So we're going to have an entire guide dedicated to how you can protect your and secure credentials or anything that you don't want to push up to version control. Within a couple of hours the hackers had already racked up over sixteen thousand dollars worth of charges and so that is not something that you want to do. I actually had a developer that was working for me that accidentally pushed up our AWS credentials one time to Github and it caused all kinds of issues. #Git status only tracked files passwordAnd there are even hackers who go through Github and they have scripts that look for different keywords such as secret or password and then they can hack your accounts based off of that. And if you push those up to this repository then everyone in the world would have access to them. So this could be API keys this could be passwords to connect to other applications different things like that. #Git status only tracked files fullIf this was a full application then you may have a few items that you don't want everyone else in the world to see. So take for example our git project right here.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |