Setting up a Github project

So I felt like setting up Github repository for awaseroot. Git is a version control system and with Github you can share your git project/repository online. We use Github as a place to share all our awaseroot material. There’s many good tutorials available (for example: http://help.github.com/win-set-up-git/) but here’s the steps I took one by one. Replace awaseroot with whatever you want.

Ubuntu 12.04
Git version 1.7.9.5

The goal is to publish this:

Like this:

First. Create an account to Github:
https://github.com/signup/free

Create a new repository:
https://github.com/new
Repository name: awaseroot
Description: https://awaseroot.wordpress.com
Public
Initialize this repository with a README
-> Create repository

Install git:
sudo apt-get -y install git

Configure git:
git config --global user.name "Firstname Lastname"
git config --global user.email awaseroot@example.com
Use the same email you used when creating the github account.

We need SSH key for the Github:
copy contents of ~/.ssh/id_rsa.pub
Or if you don’t have the key yet, create it with this first:
ssh-keygen

Log in to https://github.com
Account settings -> SSH keys
-> Add SSH key
paste the contents of the ~/.ssh/id_rsa.pub

Connect to github to authenticate:
ssh -T git@github.com

Clone the created Github repository:
git clone git@github.com:awaseroot/awaseroot.git
cd awaseroot

Add the github repository as a remote git:
git remote add awase git@github.com:awaseroot/awaseroot.git
(You can change awase to whatever you want.)

Create/add content to your project and push it to github:
cp -r ~/puppet/ ~/awaseroot/
git add puppet
git commit -m "First Puppet files added"
git push awase master

Your new pushed material should be now available in your github.
https://github.com/awaseroot/awaseroot

Becoming a collaborator to an existing github repository

So you have your git already configured, Github account ready with SSH key and now someone adds you as a collaborator. Here’s what to do:

If the repository is for example git@github.com:awaseroot/awaseroot.git
Clone the repository:
git clone git@github.com:awaseroot/awaseroot.git

You should now have the awaseroot directory. Go there:
cd awaseroot/

Add the repository as a remote:
git remote add awase git@github.com:awaseroot/awaseroot.git

Add your files if you have something to add:
cp ~/puppet/manifests/site.pp ~/awaseroot/puppet/manifests/
git add puppet/manifests/site.pp

Commit and push your changes:
git commit -m "site.pp added"
git push awase master

Everyday use

Every time you make changes to your repository you can use these commands to commit changes:
git add my_file         # add a file called my_file to git.
git add .                   # add all modified files to git and remove deleted files.
git commit -m "commit description"  # commit changes.
git push awase master  # push changes to remote git (github).
(change awase with whatever you defined as a remote)

If someone else has made changes to your git repository, pull the changes with this:
git pull awase master

You’ll get an error message if there’s new changes in your git and you try to commit before pulling
those changes.

Sources
https://github.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: