GitHub's a great tool to maintain your code, but it's definitely a little confusing the first time around (and, possibly, a few times after that). Here is a quick guide on how to use it efficiently.

To start working with GitHub, first you have to sign up on the GitHub frontpage. Once you've signed up, create a repository where all your project's code will be maintained.

Once you are all set on the GitHub site, you have to install git on your local machine.

Now you are ready to upload your local files to your repository. To do that, first we must initialize some settings in git:

Open up a terminal and enter the following two commands:

git config --global user.name "Your Name Here"

git config --global user.email "your_email@youremail.com"

Make sure that you give your GitHub email address as user.email. As user.name you can enter whatever you like.

After the initial configuration is done, you can synchronize your local files with your repository. Go to the local directory where your project's files reside and enter the command:

git init

With git, you synchronize yor files through commits. Each commit contains files that you specify to be uploaded to GitHub. To add files to a commit enter:

git add example.php

The above will add example.php to the next commit. If you want to add all files and folders, you enter the command:

git add -A

Once you are happy with the files you want uploaded to GitHub, enter the command:

git commit -m "optional message. usually the purpose of this commit, eg. why changes were made"

This will get all files you added ready for uploading to GitHub. To actually upload them, you enter the commands:

git remote add origin https://github.com/yourusername/nameofyourrepository

git push origin master

If you get an error message, it can be that the GitHub repository contains files not currently on your local folder. In that case you have to "pull"(download) them first from GitHub, before you can synchronize your project. To pull files from GitHub you enter the command:

git pull https://github.com/yourusername/nameofyourrepository

After "pulling" has finished, you can try to "push"(upload) your commit again:

git push origin master

That's it! You've "pushed" your local files to your GitHub repository.

Now whenever you make changes to your local files, you can add them to a commit and push them to the repository. You can also pull from the repository to work on other people's commits (if you're working on a team's projects). Another scenario is that you can revert to a previous commit in GitHub, and pull the files from that commit to your local folder to work on them.

1 comment    (post your own)


    Strict Standards: Non-static method birdyComments::singleComment() should not be called statically in /home/chrismic/public_html/birdy/helpers/comments/inc_rate.php on line 200
  1. Anton

Leave a Reply   

The Sinner In Me (Chris Vulture Mix) by Chris Vulture on Mixcloud