Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Thursday, May 8, 2014

How to push a project to Github

In a previous post, I mentioned that every developer should be using Github.  Github is a cloud-hosting service that creates backups of repositories, or projects.  These projects can be viewed, shared, or edited by other members of Github.  Github creates a wonderful experience because it creates a worry-free backup of your work and other people can contribute towards your work, which can create bigger and better projects.  

In order to use Github, you have to be a little bit familiar with a command-line interface, such as terminal for Mac.  It's been a few months since I've pushed a project to Github, so I thought I would go over the steps to both help you and myself.

Before I begin with the initial Github push, there are three basic steps when pushing a project.  First, edit content.  This means editing a piece of code, adding images, added documents, whatever.  Second, you commit the changes, which means you kind of create a save state.  Three, you push the save state to Github.


Step One - Create Your Repository



This is actually an easy step and it doesn't require the command-line interface.  Visit Github and perform the necessary on-screen steps. Be sure to name your repository and remember the name, because we will have to refer to it in step three.   It doesn't matter what you select for the README; we are going to wipe out the settings in a second!

Also, make sure you have a folder on your desktop for your project.  The beauty of Github is that you can work offline and then push your content online.


Step Two - Install Git



Git is required in order to push projects to Github.  If you don't have it installed already, you can actually install it from Terminal.  Follow the steps provided at the Git website.


Step Three - Initialize Git



Now that you have Git installed, you can get started!

In Terminal, cd to your local project folder on your computer.

Type the following in the Terminal:

git init

This creates a git repository in your project folder on your computer.

Then add files to the Git index:

git add .

Commit the added files:

git commit -m 'Whatever you wish to say'

Commiting is like a save state for your project.  You can add messages to help you remember where you are at within your project's progress.  This is added in between the single quotation marks.

Create a connection with Github

git remote add origin https://github.com/username/your-project.git

Make sure to change the your-project to your project's url address. You can get the url from the repository you created through Github.

Push Project to Github

git push -u origin master

This sends your commits in the master branch of Github. Basicaly, this is sending your save state to Github.

Final Thoughts


That's all!  Using Terminal for the first commit and push is required. Once you have done this, you can download a Github client that will make it easier to commit and push; it doesn't require Terminal. I prefer Github for Mac. However, you can always commit and push to Github through Terminal like we just did. This time, this is all you have to do for the next commit and push:

git add .

git commit -m "type your commit message here"

git push origin master



Thursday, February 20, 2014

GitHub: the open source backbone for your projects


If you are unfamiliar with GitHub, it is a code sharing community where programmers can network to tackle projects together.  In the beginning, it was mostly intended for code use, but now people are going beyond that and hosting non-code documents and files so that multiple people can work on one project. 

Users can host their projects on the site by “pushing” their content through Git, which is the source code management (CSM) software behind GitHub.  Linus Torvalds, who was the lead developer behind the Linux operating system, created Git in 2005.

Git operates by hosting projects in directories, or in GitHub’s case, repositories.  These repositories are then hosted on GitHub where anybody with an account can “fork” the project.  Forking a project creates a copy of the existing project and places it underneath your profile.  From here, you can continue to view the project, but the most important feature is the ability to edit the code.

My GitHub profile.


For developers, this is big.  GitHub is excellent for new open source projects.  With several developers forking and editing a project, a project can become so much more than what one person could complete.

For new users, GitHub can be kind of overwhelming.  It involves using Terminal, or whichever command-line software your operating system uses.  Because of this, many people don’t use GitHub.  To help, here are two tutorials to get started:


My two cents:

As an aspiring front-end developer, I’ve questioned whether or not it is worth using GitHub.  I recently used it for a project in which I was in South America without internet access for most of the day. 

Using GitHub actually promoted good coding practices.  GitHub provided a backup of my site in case I happened to lose or damage my laptop, which was a very strong possibility in one of the biggest cities during the rain season.

It is also promoted working offline.  I could code during the day without Internet access and push what I had completed when I arrived at the hotel.

It allowed for easy collaboration.  I worked closely with a professor during this time.  When we ran into a problem, we would fork each other’s work and push our ideas back at each other.  It was a smooth and painless process.

Finally, I had a complete project to show off on GitHub.  To me, having the final product on GitHub was like a trophy.  It documented all of my hard work; it showed every update I completed.

In the end, if you learn how to use GitHub, you’ll be strongly rewarded.  On top of learning some great coding practices and being a part of a popular, active community, you’ll have the opportunity to be a part of the next big project.  You might just fork and edit the code for the next Facebook.