GitHub is a company that implements a web-based version of git: it has a nice web interface and also a place for you to put your projects "into the cloud". GitHub offers all the functionality of git and adss some of its own (like wiki pages for each project, and social-networking-like features like feeds and followers). GitHub has 20+ million users, and it's becoming a virtual meeting place for software developpers, for sharing information and showcasing projects.
In a nutshell, a version control system lets you and your peers work and collaborate on projects, from anywhere. Initially you (or someone else) will create a remote master repository on github for your project. This master repository is hosted remotely, on github. You (and your partners, if any) will then clone (checkout) a private copy of the remote master repository on your local machine. You can clone several copies of the master repo in several locations, if you want. You can make changes to your local copy. When you are done, you stage these changes for commit, and then you push them to the master repository. Once your changes are pushed to the master repo, your partners can get them by "pulling" the changes from the master repo into their local repo. Git automatically merges the changes pulled form the master with the local changes in the local repo. Finally, git has a feature where it keeps a record of all changes, and any change can be recovered and reverted.
Before you starting using the Git command on the command line, you need to give it a basic configuration. This will tell Git who you are, making it easy for you and your partners to identify who committed code to your shared repository. Replace the email and name strings with your email address and name. If you have not run these commands, then the very first Git commit will fail and tell you to run them.
git config --global user.email "username@bowdoin.edu" git config --global user.name "Your Name" git config --global push.default simple
First, you'll clone the master repository. To do this you will go to the path where you want to place your local directory. Let's say you want it on your Desktop:
cd DesktopThe first time you clone, you'll probably want to create a folder called "algorithms":
mkdir algorithmsThen you'll go to that directory:
cd algorithmsAnd you'll clone:
git clone https://github.com/lauratoma/helloworld.gitOnce cloned, the usual work cycle in Git is pull-edit-commit-push-repeat:
cd Desktop/algorithms cd helloworld git pullYour local repo is sync-ed with the master repo.
git statusthis will show you what files are modified.
Now stage the files that you want to commit:
git add file-which-you-want-to-commitFor example let's say you modified helloworld.c.
git add helloworld.cNote: do not add object files and executables to the repo.
git commit -m "describe what the changes represent"Note that commit does not take file names as arguments, and will update the local repo with the files that have been staged. Files that have not been specifically staged for commit, will not be commited.
git push
That's it! We'll push branching later (pardon the pun).