This page is a example of using the various git hosting websites. If you are not familiar with git, see: git Tutorial.
How to get code from github?
Go to a github site, ⁖ https://github.com/xahlee/. Click on a project. Then, at the top there should be a field showing URL, like this: 〔https://github.com/xahlee/xahscripts.git〕. Then, do this:
git clone https://github.com/xahlee/xahscripts.git
This will create a dir of the project name (xahscripts) in your current dir.
How to put your git repository on github.
First, go to https://github.com/ to create a account.
Now, create a new project. On github site, click the “Create a New Repo” button, then fill out the form. (you have to do this on their site. (or use their API))
On your machine, create your git repo if it doesn't exist. ⁖ cd to your project dir, then:
cd ‹your project dir› git init git add . git commit . -m"initial commit"
On your machine, cd to your project dir, then create a association of a name and a remote repository URL. Like this:
# Associate the name “github” with the URL of remote of remote repository git remote add github https://github.com/‹github login name›/‹project name›.git # example of actual command: # git remote add github https://github.com/xahlee/xah_emacs_init.git
This will associate the name “github” with that URL. So later on, you don't have to type the full URL when you want to push code to github.
To push, do: git push github master. This will put the “master” branch to the remote server. You can add a “-u” (--set-upstream) option. The “-u” option will save you from typing a remote server name when you do git pull.
To pull, do: git pull github master. This will update your local repository from remote server.
Example of a Google Code project using git: http://code.google.com/p/ergoemacs/
Guest checkout example:
git clone https://code.google.com/p/‹projectname›/
Owner checkout example:
git clone https://‹username›@code.google.com/p/‹projectname›/
Push example:
git remote add googlecode https://code.google.com/p/‹projectname› git push --all googlecode
See also: Convert Your code.google.com Project from svn to git.
gitcafe.com is a git hosting website for Chinese.
My gitcafe URL: https://gitcafe.com/xahlee/
First, go to the site to create a account.
Then setup ssh key. Here's how to generate ssh key:
# generating a ssh rsa key for gitcafe site ssh-keygen -t rsa -C "your_email@example.com" -f ~/.ssh/gitcafe
This will create 2 files:
Copy the content of your public key, and go to https://gitcafe.com/account (login first), and paste it there. 〔☛ Intro to Public-key Cryptography for Sys Admin; What's HTTPS, SSH, SSL, TLS, AES, SHA-1, MD5, …〕
then, create this file 〔~/.ssh/config〕 and add these lines:
Host gitcafe.com www.gitcafe.com
IdentityFile ~/.ssh/gitcafe
Then, on gitcafe website, click to create a new project.
Then, on your machine, add gitcafe URL:
cd ‹existing dir of git repository› # associate a name to a git project remote repository git remote add gitcafe git@gitcafe.com:xahlee/xah_emacs_init.git # push the master branch to a remote server named “gitcafe” git push gitcafe master