Getting Set Up with Your Projects on Github

So you want to use git to manage your projects?

Make sure you’ve installed git:

To make a new repo:

Once you’ve created the repo on github follow the “next steps” it gives you. There are just a bunch of one liners you can enter into your terminal.

If the repo already exists?

cd {to the directory where you wan to store the repo}
git clone{your_user_name}/{example_repo_name}.git

Watch git do some magic, then:

cd {repo name}

And your off and running.

How it works?

The process goes something like this.

  1. Make sure you do “git pull” before you start working on your project for the day. This will ensure you merge any changes that other may have made to your repo over night.
    git pull origin master
  2. Work work work…
  3. When you think your ready to upload some changes, add your changes
    git add .
  4. Then you need to commit your changes to the repo
    git commit -am "added some stuff"
  5. After everything is done, push your changes to github
    git push origin master

You should be all set.


There’s an excellent article here about branching and merging. The basic idea is to have a “master” branch, that is designated as “read for production deployment”. Meaning anything that goes on master can be copied directly to the server and expected to run. If we’re working on a bugfix, we make a “bugfix” branch. This essentially copies the master and allows you to make changes, when your ready to push changes, you push them to the bugfix branch. This way we can share our bug fixes with the team. Once we’ve concluded that the bugfixes are working, a team member in charge of the repo will merge the “bugfix” with “master” and handle any conflicts.

Let’s say I Katy walks into my office and says, “your shit ait’t workin’ and it’s all messed up!” I quickly do a “git pull” of my master branch to make sure I’m up to date. Then I do the following:

Create a new branch to start this “hotfix”. I name it “hotfix1”:

git branch hotfix1

Then I want to switch to that branch:

git checkout hotfix1

Now I can start making changes. Let’s say I figure out the issue and am confident the branch contains the fix.

git add .
git commit -am "fixed this shit"
git push origin hotfix1

I’ve pushed the hotfix to the repo, my other team members can pull that branch from the repo, run it locally and verify that it’s working. Once we’ve confirmed, our team member in charge of the repo can merge the “hotfix1” branch to master. Then we can all pull down the master branch and the fix is permanent.

Now let’s say I’ve pushed the branch and my team members are in the process of verifying that it works. In the mean time I just want to update the server with the latest master just to make sure the problem isn’t someplace else. I change back to the master branch:

git checkout master

And git automatically changes the files on my system to reflect what I had for “master” instead of “hotfix1”. So I can take master, upload it to the server and be confident that it will run. Once my team members have confirmed my hotfix, I can pull down the latest master and delete my local copy of “hotfix1”

git checkout master
git pull origin master
git branch -d hotfix1




Leave a Reply

Your email address will not be published. Required fields are marked *