As you may know I’ve been using git as my primary ftp, version control and way to put my projects online for public access and viewing. However, there is a very important thing when considering using these great technology: .gitignore.
Now, when using oAuth, you need a client identity and a client secret. For me, I don’t want to hard code them because that will make them publicly accessible so I stored them in a json file. I thought I followed ignoring the json by adding
to the .git/info/exclude file, however I did not do it right
as ^(.*)/secret.(.*)$ is different than ^(.*)secret\.(.*)$ and quite possibly is completely incorrect
Now first i uploaded it to github, only to find that the file was still there. This through to a flurry as for the last three commits I had assumed everything was peachy clean (I am still learning everything so I don’t hate myself for it. Luckily I was able to find this tutorial on github.
Not only was I able to remove my secret from the commit, but also able to add to the .gitignore in a simple manner. My fears relaxed and a feeling for relief ensued.
Just to add to the security, I also made a proper .htaccess to hide the file
RewriteRule ^(.*)secret\.(.*)$ /404 [L]
So one of the things I’d prefer to do is to work on my website locally then push to github and my server. Easy to say like most concepts…
Now at times I just don’t want to figure things out, as such I chose to use someone elses work. This is a great Article on it. Now despite following the tutorial to a T I ran into issues, not because its a bad tutorial, because for anything, the amount of work and research that goes into something like this is very very very commendable. No work should ever be downplayed, though Its important to look at what is flawed.
I’m not going to rewrite the article but theres a few peices you will want to keep in mind
1) When editing your files from the shell, your most likely going to have to use vi the reason for this is you would have to install other file editors to use them
2) The Command
git remote set-url origin ssh://email@example.com/~/repo/app_name.git
git remote add origin ssh://firstname.lastname@example.org/~/repo/app_name.git
this may seem small, but you’ll be running into headaches if you don’t pay attention
3) if you’d like to include github to the mix, I’ll want to setup an ssh key for github https://help.github.com/articles/generating-ssh-keys
then in a similar fassion
git remote add github email@example.com:UserName/Repository.git
4) Get used to the following commands
-As I’m relatively new to git, I kinda learning the important aspects
Remember to change your directory to the working directory
git add .
git commit -m "your message" .
git push github master
git push origin master
I might store this in a script that I’ll just run as needed