Author - Web Developer - Educator
Found 3 results for tag "git"
RSS Feed

My Journey into Git

Git logo

My Journey


My journey to discovering git was not an easy one. Since git was not covered in my formal programming lessons, I had to learn "version control" the hard way - the very hard way.

When I started learning HTML back in 2001, I learned to save and modify local files only. In 2002, I learned PHP and MySQL by working on a team server, but version control was not introduced (git was introduced to the world in 2005, but options like CVS or SVK weren't taught). My first local server came in 2004, when I learned to FTP files, instead of testing local files only.

I quickly updated to SSH'ing into the server and editing the direct code, and backuped the files using a combination of file extensions (such as .bak, date stamps like.20150515, and "Backup 20140523" folders).

...and I used this method up to about a year ago, when I took a git intro course online. Unfortunatly, I didn't quite understand the purpose of git because the demos kept talking about files that either already existed, or branches that were made by someone else - never really diving into the underlying purpose of git, which was version control.

I also couldn't get used to the idea of uploading my database login information (along with other private code) to the public site GitHub, which is great for open-sourced projects (see mine here), but not great for a company version control backup. So I dabbled in git for a while, until it hit me about a month ago: I could use git on my own server(s) and not have to deal with private repositories on GitHub (or the prices).

So, I started using git on my server for backups of projects site-wide. Then, I wanted to deal with errors on a non-production server basis (I didn't want the world to see my error testing, because that would be unprofessional). After getting a local Apache server, and MySQL server, and installing PHP (on Windows), I thought that I could use the GitHub software to create backups - but that was only for the GitHub site; I needed something to work with my own existing servers. Therefore, I installed Cygwin and got the Linux-enabled commands with git to my production server.

Overall, this is what I learned, and I hope it helps others:
The Process
The "direct" process vs the git process

Usage


(If you don't already have git set up on your remote server, then please do so by installing it - I recommend sudo apt-get install -y git. Otherwise, this won't work, and it's just a bunch of lines of code)
The SetupRemote (seperate from production folder):
mkdir [dir].git && cd $_
 
git init --bare
 
cp ~/post-receive.sample hooks/post-receive

The hooks folder deals with webhooks to automatically catch incoming files and do something with them (or at least, that's what I've discovered). To make the hooks run properly, you need a post-receive file, and this is what it should look like:
post-receive.sample
#!/bin/sh
 
GIT_WORK_TREE=[absolute path to production] git checkout -f


Once you have that set up, you can work on your local machine to create and modify files.
Local development machine
# If files do not exist
 
git clone [email protected]:[dir].git 
 
cd [dir]
 
# If files DO exist/update
 
cd [dir]
 
git pull
 

 
# Time for editing
 
vim [file]
 
[...]
 
[work on files, test on development machine]
 
[...]
 
(Ready to upload to production server)
 
git add [file(s) - * works as well]
 
git commit -m "Relevant message to update"
 
git push


One important note: As I have learned, your Git folder is not your production folder. I had my .git folder in my production folder of a project, and it was good for local editing, but not remote pulling. If your project folder (example: project.git) is somewhere else, like your home folder, then you can use the post-receive webhook to automatically pull committed files to the production area

Bonus: SSH Login w/o PW


Unless you want to type in your login information every time you git push, I recommend setting it up so your local machine/development server can automatically upload to the production server. If you are running a Linux system (and I recommend you do), then you can do the following:
SSH Password-less LoginOn your local machine (hopefully a Cygwin or Linux/Mac Terminal)
ssh keygen -t rsa
 
ssh [email protected] 'mkdir -p .ssh'
 
cat .ssh/id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys'
B = Remote server



Summary


There is still quite a lot I don't understand about git (like branches, merging, etc), but I am getting better. I've been using this guide as a resource, as many other guides are very technical for a non-git person.

My takeaway: Better integration into team development instead of just "solo development"


Tags:#git #development #php #mysql #html #linux

RSS Feed

My First Mobile App

I've been trying to push my limits for the past few days, to make up for the fact that I've been very de-motivated. So, I decided to pick up the progress on WNC Local, which has been going well. I've also been working on the WePay API as well, and that's been...enlighetning? It's been a little challenging, but it's good to get the experience.

So, to take a break from the many hours I've spent slaving over the API, I decided to switch directions for a bit and start tackling the Android and see what I can do with mobile apps. Not having a speck of knowledge in Java, it is a real challenge.

However, thanks to the Android SDK bundle, the Eclipse IDE was included (I've had experience with Eclipse when I was working on C++ back in 2003), and Eclipse+Android Development Toolkit (ADT), getting to "Hello World" was fairly simple.

Using the techniques mentioned on the basic training page, I created the following:
My First App Icon
(Yes, that is Asuna in the background)

My First App

The basic training allowed for the creation of the basic app: input text, output the text.
My First App Output

The documentation was not completely fool-proof, so I had to do some additional research to do a few things (thanks to Toast), like this:
Search Button Pressed

Settings Button Pressed

And the documentation didn't go this far, so I thought I'd add this based on some UI experiences:
String cannot be Blank

I know it's not a very impressive app, but it's not bad for my 1st one done within an hour.

In case you want to fork it or view the source code, I have the app on Github: https://github.com/kode29/MyFirstApp

Here's the APK if you want it

Here's to seeing what Mobile App Development can do!


Tags:#android #app #development #github #wnclocal #wepay #c++ #sdk #eclipse #ide #adt

RSS Feed

Hittin' the Tracks with Rails

Well, more like a "Ruby" and "Ruby on Rails" scenario, if you know what I mean.

Anyway, here's a comic that I wish I could create:
FatCats


Getting back to the topic, I've been going through the Codecademy's track for Ruby to understand the concepts for Ruby (I went through all 10 courses they had within 11 hours), then studied up with RailsForZombies.org and Rails Tutorial book to get a grasp on Rails. I've been working on that book for about 2 days now, and it has really shown me the in's and out's of a basic dynamic rails structure. I'm on Chapter 7 right now.

All I can say is that Ruby seems very robust, but Rails seems very picky.

It is a different standard from what I'm used to with PHP. Whereas Rails is extremely picky with "only my way works" (kind of like older HTML), I'm used ti the PHP mindset where "if you have an idea, there are about 50 ways to create it". Personally, I still like the PHP way, but I haven't given up on RoR yet, but I like the MVC procedures that Rails incorporates (and now that I can finally use git for a good reason). You can checkout my progress at http://cdn.kmp.link:3000 or even view my github releases at https://github.com/kode29/sample_app.

On the lighter side, I've created a "Skillset Chart" on my blog showing off some of my skillsets and how experienced I am with them. Just view the middle right section of my blog layout to view it.


Tags:#fatcats #rails #ruby #ror #php #html #github