1、下载安装Git并初始化
git config --global user.name "***"
git config --global user.email "
***
***"
git config --global color.ui auto
2、创建帐户
3、设置SSH Key
$ ssh-keygen -t rsa -C "******"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Documents and Settings/Administrator/.ssh/id_rsa):
Created directory '/c/Documents and Settings/Administrator/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Documents and Settings/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Documents and Settings/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
***
*** ******
4、添加公钥,查看 id_rsa.pub 文件内容
SSH Keys
id_rsa id_rsa.pub
$ cat ~/.ssh/id_rsa.pub
ssh-rsa
***
***
***
***
5、与GitHub认证和通信
$ ssh -T git@github.com
Enter passphrase for key '/c/Documents and Settings/Administrator/.ssh/id_rsa':
Hi
***
***! You've successfully authenticated, but GitHub does not provide she
ll access.
6、创建仓库(New repository)
https://github.com/username/Project
7、公开代码
1)clone已有仓库
$ git clone git@github.com:******/******.git
Cloning into '
***
***'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Checking connectivity... done
2)显示状态
$ git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# hello_world.php
nothing added to commit but untracked files present (use "git add" to track)
3)提交
$ git add hello_world.php
$ git commit -m "Add hello world script by php"
[master d6e3859] Add hello world script by php
1 file changed, 3 insertions(+)
create mode 100644 hello_world.php
4)查看日志
$ git log
commit d6e3859f21141ccd7ae5e764e31befed5bda92ca
Author:
***
***
Date: Thu Feb 11 18:10:26 2016 +0800
Add hello world script by php
commit ea83909b650c46ad3d513b7f54d72d021dee31b8
Author:
***
***
Date: Thu Feb 11 17:51:21 2016 +0800
Initial commit
5)进行push
$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Enter passphrase for key '/c/Documents and Settings/Administrator/.ssh/id_rsa':
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 324 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
ea83909..d6e3859 master -> master
本文详细介绍了如何使用GitHub进行项目管理及代码分享,包括Git的下载安装、GitHub账户注册、SSH Key配置、仓库创建与代码提交等步骤。
911

被折叠的 条评论
为什么被折叠?



