GitHub入门与实践(1)GitHub 前期准备

本文详细介绍了如何使用GitHub进行项目管理及代码分享,包括Git的下载安装、GitHub账户注册、SSH Key配置、仓库创建与代码提交等步骤。
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)
To  git@github.com: *** ***/******
   ea83909..d6e3859  master -> master








内容概要:本文详细介绍了GitHub的功能及其在软件开发中的应用,涵盖了从创建账户到使用GitHub进行协作开发的全过程。首先,文章解释了GitHub不仅仅是Git仓库的托管服务,它为开发者提供了一个面向人的协作平台,支持社会化编程。接着,逐步指导读者如何安装Git、配置SSH密钥、创建和管理仓库、使用Git基本命令(如init、status、add、commit、log、diff等)、创建和管理分支、推送和获取远程仓库内容、使用Pull Request等功能。此外,还深入讲解了Issue、Wiki、Notifications等辅助功能,并介绍了几种GitHub集成的工具和服务,如Travis CI、Coveralls、Gemnasium、Code Climate和Jenkins。最后,文章探讨了两种常见的开发流程:GitHub Flow(以部署为中心)和Git Flow(以发布为中心),并分析了企业引入GitHub的利弊。 适合人群:具备一定编程基础,尤其是对版本控制系统有一定了解的研发人员,包括新手和有经验的开发者。 使用场景及目标:①学习如何创建和管理GitHub账户,理解其主要功能;②掌握Git的基本操作和分支管理;③了解如何通过Pull Request进行代码审查和协作;④熟悉Issue、Wiki等辅助工具的使用;⑤探索GitHub集成的CI/CD工具和服务;⑥理解GitHub Flow和Git Flow这两种开发模式及其应用场景;⑦评估企业引入GitHub的可能性和实施方案。 其他说明:本文不仅介绍了GitHub的基础功能和操作,还强调了良好的开发习惯和团队协作的重要性,如保持Pull Request体积小、定期更新代码、重视测试等。此外,对于企业用户,文章还特别提到了GitHub Enterprise的优缺点以及适合引入的情况。通过这些内容,读者不仅能掌握GitHub的具体操作,还能提升团队开发效率和代码质量。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值