使用GitHub上传管理自己代码

最近突然觉得自己代码很乱,svn之类的貌似都要搭建服务器,对于学生党实在不合适,于是决定把代码上传到gitbub进行管理。


  1. 创建GitHub账号

Github网址:https://github.com

创建自己的账号。


2.  下载安装Git

下载最新版本的Git,GitHub上提供了一个地址:http://github-windows.s3.amazonaws.com/GitHubSetup.exe

Windows版本的可以去这里下载:http://code.google.com/p/msysgit/

好像地址变更了:http://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git



直接点击下一步进行傻瓜式安装,安装好之后进行以下设置:

开始做一些简单的配置。配置user.name和user.email


(1)First you need to tell git your name, so that it can properly label the commits you make.

设置Git的user.name,方便标定你每次的Commit

[plain]  view plain copy
  1. git config --global user.name "Your Name Here"  

(2)Git saves your email address into the commits you make. We use the email address to associate your commits with your GitHub account.

设置Git的user.email,每一次的Commit,Git都会保存你的Email。Github会根据这个email,将你的commits和github账号关联起来。

[plain]  view plain copy
  1. git config --global user.email "your_email@youremail.com"  

Your email address for Git should be the same one associated with your GitHub account. If it is not, see  this guide  for help adding additional emails to your GitHub account. If you want to keep your email address hidden,  this guide  may be useful to you.

一般情况下,你git的email应该和你的github账号的email相同。

The steps listed above show you how to set your user info globally. This means that no matter which repository you work in on your computer, you'll be making commits as that user. If you find yourself needing to make commits with different user info for a specific repository (perhaps for work vs. personal projects), you will have to change the info in that repository itself.

设置user.name和user.email是为了让git记录每次提交的人是谁,之前设置是global的user.name,那么无论你在那个仓库提交,你的名字都是他,如果你希望在指定的仓库中提交时,使用指定的名字,你可以进入该仓库的文件夹,输入:

[plain]  view plain copy
  1. $cd my_other_repo  
  2. # Changes the working directory to the repository you need to switch info for  
  3. $git config user.name "Different Name"  
  4. # Sets the user's name for this specific repository  
  5. $git config user.email "differentemail@email.com"  
  6. # Sets the user's email for this specific repository  





3. Create A Repo 创建仓库

登录Github,点击New Repository



得到如下




填一个Repository Name就可以了,其他的,README可以初始化,也可以不初始化,下一步就是直接在GitHash里面创建一个README。

(1)创建一个README


Hello-World是项目名字,我自己的项目位于D:\JAVACode\JavaProjects,在Bash中执行以下命令可以指向D盘下面的项目:



(2)Commit你的README


git add命令后面添加需要上传的文件,定位到需要上传的项目之后,后面添加需要上传的文件名字,或者git add .添加项目中的所有文件。


git comment -m ‘comment content'添加此次上传的注释

(3)Push你的Commit

So far everything you've done has been in your local repository, meaning you still haven't done anything on GitHub yet. To connect your local repository to your GitHub account, you will need to set a remote for your repo and push your commits to it:

到目前为止,你在本地的仓库进行了操作,但是你还没有push到Github远程服务器的仓库。


Now if you look at your repository on GitHub, you will see your README has been added to it.

可以到你的Github上去看,是否有更新。

附上自己的执行过程和最后结果:



参考文章:

http://blog.csdn.net/benw1988/article/details/8492493

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值