最近突然觉得自己代码很乱,svn之类的貌似都要搭建服务器,对于学生党实在不合适,于是决定把代码上传到gitbub进行管理。
- 创建GitHub账号
Github网址:https://github.com
创建自己的账号。
2. 下载安装Git
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
- 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账号关联起来。
- 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,那么无论你在那个仓库提交,你的名字都是他,如果你希望在指定的仓库中提交时,使用指定的名字,你可以进入该仓库的文件夹,输入:
- $cd my_other_repo
- # Changes the working directory to the repository you need to switch info for
- $git config user.name "Different Name"
- # Sets the user's name for this specific repository
- $git config user.email "differentemail@email.com"
- # 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盘下面的项目:
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