Monday 1 February 2010

Git与Github快速上手1:上传第一个项目

给团队的文档,所以干脆利落,贴到这里分享下

本地配置

安装就跳过了,ubuntu上apt,CentOS上yum, Mac上port都有

$ ssh-keygen -t dsa
这里输入两遍密码
Generating public/private dsa key pair.
Enter file in which to save the key (/home/django/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/django/.ssh/id_dsa.
Your public key has been saved in /home/django/.ssh/id_dsa.pub.
$ cd /home/django/.ssh/
$ ls
id_dsa  id_dsa.pub  known_hosts
$ more id_dsa.pub
ssh-dssAAAAB3............................

Github注册

https://github.com 注册后选择“Create Repositories”,输入名字后会显示教程。
把刚才生成的.pub 放到github上SSH Public Keys处即可,注意不要有换行

上传项目

django@django-desktop:~/workspace/django/newtest$ git init
django@django-desktop:~/workspace/django/newtest$ git config --global user.name "xxd"
django@django-desktop:~/workspace/django/newtest/ git config --global user.email xuexiaodong79@gmail.com
django@django-desktop:~/workspace/django/newtest$ git status
使用 git add 放入想加入的
git add *.py
git add *.html
加入全部 git add . 
或者 使用.gitignore配置文件去除不想加入的,首先建立.gitignore然后输入
*.pyc
*.*#
*.*~
django@django-desktop:~/workspace/django/newtest$ git commit -m 'first commit'
[master (root-commit) dfb8880] first commit
17 files changed, 266 insertions(+), 0 deletions(-)
create mode 100644 __init__.py
create mode 100644 add.py
create mode 100644 csv_test.py
create mode 100644 data.csv
create mode 100644 helloworld.py
create mode 100644 list.py
create mode 100644 login.py
create mode 100755 manage.py
create mode 100644 readme.txt
create mode 100644 settings.py
create mode 100644 templates/address/address_list.html
create mode 100644 templates/cvs.html
create mode 100644 templates/error.html
create mode 100644 templates/list.html
create mode 100644 templates/login.html
create mode 100644 templates/wiki/edit.html
create mode 100644 templates/wiki/page.html
create mode 100644 urls.py
django@django-desktop:~/workspace/django/newtest$ git remote add origin git@github.com:xxd/newtest.git
django@django-desktop:~/workspace/django/newtest$ git push -u origin master
Enter passphrase for key '/home/django/.ssh/id_dsa':
Counting objects: 23, done.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (23/23), 5.30 KiB, done.
Total 23 (delta 0), reused 0 (delta 0)
To git@github.com:xxd/test.git
* [new branch]      master -> master
Branch master set up to track remote branch master from origin.

 

--EOF--

No comments: