git

All posts tagged git

Getting Started with Programming

y83Je1OC6Wc

A friend of mine called me up recently to ask me how to get started with programming. I’ve gotten these requests more and more as the demand for programmers rises. I’m going to compile a list of resources to help anyone get started with what I feel are the basis for what anyone who wants to program will need. This list is by no means comprehensive and while this will get you started you should not feel like you can go from knowing nothing to building the next Facebook simply by following this guide. It will, however, give you a solid foundation with which you can build and grow to the point where you could potentially build something like Facebook or Instagram on your own or working with a small team.

Which Language Should I Learn?

This depends entirely on what you are trying to do. Some people want to make their work life more efficient by writing small programs to automate their daily tasks while others may want to create websites and web applications. For the first I suggest Python. It is easy to pick up for beginners, it forces good code formatting, and it can be extended to do a large amount of things including creating large websites and applications (Instagram runs on Django which is a web framework built on Python). If you really want to write web applications or create interactive websites I would recommend learning Ruby on Rails. I have written web applications in both languages and I am far more effective in Rails thanks to their mantra of “Convention over Configuration”. I’ll be writing a post about why I feel Rails is better than Django later. Pick your language based on your goals and read the online books I have linked below. They will help you set up your computer and teach you how to create very simple programs for you to have a good base of understanding for programming.

Great Starters Guides

Code Editor

You’ll need a program to actually write the code. I personally suggest Sublime Text 3. It is free, light-weight, and can edit any type of programming file. It has a lot of neat extensions and themes so you can customize it to fit your needs.

Learn Git

Once you have picked your language of choice, no matter what it is, you’ll want to learn Git. Git is a tool to help you version your project and files. Versioning is similar to saving but gives you specific moments to return to. Let’s say you are working on a Word document. You start writing a lot, hit save, then you write a bunch more but decide you hate all that and want to return to where it was when you hit save initially. You could hit CTRL+Z a bunch but it would be nicer if you could point to a specific version of the file and say “I want to start from there again.” With Git you can do that. You make commits, marking moments in time, with messages about the changes made. If you ever want to go back you can simply rollback to any previous commit undoing your current changes. This is useful when you have a working program and then start to do some complicated work only to find you have totally screwed up the project. Just roll back to when it was working and start again.

Github

While you can use versioning locally for your small projects you really start to see its true power when you make your software available for others to review and help; this is known as open-source software. Create an account on Github and they will guide you in pushing your local git versioned projects into projects that anyone can see and help you with. Don’t be afraid of others seeing what you might consider “bad code”. The point of doing this is so others can help you learn and progress. When you have a larger project others can write features and submit bug fixes for your code as well. Once you have a firm grasp of whatever language you have chosen you can even write code for other open source projects to help them with their features and bugs.

Conclusion

Everyone should learn a little bit of programming just like everyone learns a little bit of math. Obviously we can go very deep into mathematics and we can do the same with programming but everyone should have a grasp of the basics and have a foundation even if you don’t do it professionally. I hope this guide was useful and let me know if you have any questions or concerns in the comments below.

gitlab_0

GitHub is great for open source projects and if you haven’t been there to see what’s going on you’re missing out.  They offer free git hosting for all of your open source projects.  Their UI is great for tracking issues, commits, users, updates, and so much more.  But let’s say you want to use all of that great UI on a project you don’t want open source.  That’s when you’ll need to pay GitHub for a few private repositories.  Or maybe you want to create an organization for you and your developers to create private projects and manage larger applications across many repositories.  You’ll need to pay for that too.  Below are the price lists for both personal repositories and for organizations.

organizationpricing

Those prices can get pretty steep.  Luckily for you there is an open source solution to GitHub called GitLab.  It runs on Ruby and you can set it up all by yourself by following these GitLab Installation Instructions.  That assumes you have a server ready to serve and work for you.  If you don’t you can quickly set up a great Amazon EC2 instance and install GitLab in one click.  There are a couple of caveats in getting things set up with the EC2.  Once it is installed you’ll log in using the account user@example.com and the password is contained in your EC2 log.  Once logged in change your password to something other than the auto created one.  You’ll then need to make some changes to your config files.  SSH into your EC2 instance and update the URL contained in ~/apps/gitlab/htdocs/config/gitlab.yml.  Follow the instructions at the top of that file.  Then you’ll need to set up your email service.  To do that follow the instructions here and then restart the services as described at the bottom of that section.  Now you’re all set!  Placing this in a free Amazon instance will give you a server for a year for free and then after will only cost ~$15 per month.  Much cheaper than GitHub and you have complete control to create groups, private repositories, even public repositories!

That’s all there is to it.  I’ve started using it for my personal projects that I want a UI for issue tracking and other users to join me with and not make public.  If you have any great advice for using GitLab feel free to share in the comments below.

Git-Logo-1788C

We recently moved our git repositories over to Amazon Web Services.  We ran into one issue with it which was that now our git requests needed to have a key pair attached.  The Internet was not very kind on explaining how to do this very well so I’m documenting it here.

The key pair you’ll want to use is the one generated for you by AWS.  It is the same one you use when you ssh into your AWS EC2 instances.  Take this key pair file, which I will call keypair.pem from now on, and we’ll need to move it and configure our git to use it.

  1. Copy the keypair.pem into your .ssh folder.
  2. Create/open your .ssh config file.
  3. In your config file
  4.  To clone the repository use the following
  5. To update existing projects on your machine to use the new address follow the instructions below
  6. Open your project’s git config file
  7. Change the url line to be

That’s it. Hope this helps anyone who is getting the error ‘Error: Permission denied (publickey)’.  There are other ways to do this but this way was pretty easy.

git

I’ve found that a lot of things on Ubuntu are very easy to install but there are some trickery ones that if you don’t know the procedure can be a pain to get up and running on a new installation.  Here is a quick setup guide for getting SmartGit installed on a fresh Ubuntu installation.

  1. Install the Java Runtime Environment from here.  http://apt.ubuntu.com/p/openjdk-7-jre
  2. Install Git with the command sudo apt-get install git-core
  3. Install Mercurial with the command sudo apt-get install mercurial meld
  4. Download and install SmartGit per their instructions on their site

That’s all there is to it.  Hope this helps both myself and anyone else looking for a quick guide to get SmartGit up and running.