Friday, 17 October 2014

Creating a Git Repository

"GitHub is a Git repository web-based hosting service, which offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features. Unlike Git, which is strictly a command-line tool, GitHub provides a web-based graphical interface and desktop as well as mobile integration. It also provides access control and several collaboration features such as wikis, task management, and bug tracking and feature requests for every project." (http://en.wikipedia.org/wiki/GitHub)


I have just set up a Github profile for the Lady Coder blog, which you can see over at this URL: https://github.com/theladycoder/




I then created a repository (or 'repo') for all the demos and code samples we'll be looking at on the blog. The repo is available at this URL:

https://github.com/theladycoder/demos

----------------------------------------------

Getting Started


So! Below are all the steps that I took to first configure Git, and then to create the 'demos' repo. I am working on Windows, but I'm sure the commands are fairly similar on other operating systems.

First, I downloaded and installed Git Bash, which you can find here:

http://git-scm.com/

Once installed, change to the directory you want to work in. In my case, I wanted to work in a folder that Windows would call "D:\git\theladycoder\", which would contain all the repo's. I created a new folder for the 'demos' repo, and then in Git Bash, I typed:

cd /d/git/theladycoder/demos/

This will change to the directory that you are working in.

----------------------------------------------

Changing config settings


I was referring to the tutorial at the URL below for this config section:

http://git-scm.com/book/en/Getting-Started-First-Time-Git-Setup

First, create a .git folder. You must do this via the mkdir command in bash, since Windows doesn't allow it:

mkdir .git

Next, create a file inside the folder called "config". This file will contain the config settings which are relevant to your project. There is also a 'global' config, but we're not touching this here.


The first config you'll want to add is your user name. Do this as follows:

git config user.name "Lynn Carroway"

Similarly, add your email address:

git config user.email "your.email@gmail.com"


Anytime you want to check your config settings, you can just type in 'config --list':

git config --list

That's it! Now we've set up the config for your Git repository.

----------------------------------------------

Creating the Repo


Git recommends that each repo have a readme file, which describes the project and contains any useful info. Create the readme file like this:

touch README.md

Next, we'll want to initialize the repo, which adds a bunch of folders in the .git folder:

git init

Now, add the readme:

git add README.md

Note that the 'add' command is case-sensitive, so you'll want to add the capitals in README.md.

Ok, now we're ready for the first commit:

git commit -m "first commit"

Now, we need to tell Git where we want to add the repo, which Git calls the 'origin':

git remote add origin https://github.com/theladycoder/demos.git

Now everything is set up, we can perform the push:

git push -u origin master

After entering the 'push' command above, you'll be prompted to enter your Github usename & password.

Oops! What happens if you try the command above, and get the following error:


error: src refspec master does not match any
error: failed to push some refs to

What this error refers to is that there are some files in the directory that Git doesn't yet know about. You need to 'add' the files to the repo. The simplest way to do this is to use a '.' after the 'add' command, which will add all files in the directory:

git add .


You should now be able to push the directory to the Github repository:

git push -u origin master

----------------------------------------------

That's about it! You have now created a new repo, and pushed it to Github.

What are your thoughts? If you have comments or additions, please reply below. Also, if you like the tutorial, please 'Like' it, using the social media buttons.


Tuesday, 14 October 2014

A First Post

Welcome to the lady coder blog - a collaborative and interactive blog for JavaScript, HTML 5, CSS (and related topics) by and for women.

The lady coder blog is also my personal blog and so I am sure there will be snippets about the things that interest me - fashion, travel, fitness and other topics to keep things interesting. Overall, I'll be writing about my adventures in JavaScript and social media.

On the subject of social media, here's a quick mention of how much fun I've been having with Pinterest! Making boards and pinning items isn't challenging in any way, but it's fun and I get the same fulfilling feeling from making a Pinterest board as I might after having written a poem, or a blog post.

Take a look at one of my boards here (and please feel free to follow me!):

http://www.pinterest.com/lynncarroway/womens-fashion/


The Lady Coder's pin