"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
----------------------------------------------
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.