Create a Github Repository
By far, the easiest and error-free method of using a Github Repository, is by starting with a new repository on github.com itself. Of course, you need a github account first.
Clone the Github Repository to Local
To clone a Github repository, use the following command:
git clone https://github.com/catch22eu/project-directory.git
This wil create a new directory project-directory, and copy all the repository content on Github to this directory. Besides, it will also create a .git directory containing the administrative files needed to keep track of your changes.
Add files or edit the Local Repository
cd into the directory that has just been created, and edit or add files to your preference. In order to update the changes to the local repository database, use the command
git add .
This will synchronise the new or added files (to what is called the staging area).
Committing updates to the Local Repository
By now, the local repository is aware of the changes, but they need committing by you as a user to make the system also aware of different versions:
git commit -m "Info of the changes and / or versioning here"
Beware, that prior to this, you'll have to use two commands to define your "global" user name and email address if you did not do this before:
git config -global user.name "your name"
git config -global user.email you@email-address
Pushing the changes to Github
Simply use:
git push
This will push the changes to the github server. The command will ask for your Github username and password before sending the files. A look at the github.com will then show your changes or additions as well.
Updating the Local Repository with a newer version from Github
First, archive any changes made on the local repository (if there are no changes, it will say so as well):
git stash
Then pull the newer version from Github and update the local repository:
git pull
Conclusion
That's all there is. For more information, and other options, see github.com.