初试git+github(linux环境)

时间:2022-04-27
本文章向大家介绍初试git+github(linux环境),主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1、注册github,并创建代码库

        地址:https://github.com/

        注册github,登陆后, 点击右上角 “Create a new repo” 按钮,Repository name输入Hello-world, 选中 public ,

        点击Create repository按钮,库创建成功。

2、安装git,并设置git

        下载地址http://code.google.com/p/git-core/downloads/list

        安装完git后,执行:

git config --global user.name "Your Name Here"
git config --global user.email "your_email@youremail.com"

        user.name 为全局的用户名

        user.email 为github的注册邮箱,用于与github关联。        

3、创建本地库,并提交原始版本文件

        在主目录中创建Hello-world目录,进入该目录,执行git init,出现.git的隐藏子目录;创建README文件作为测试提交的文件,vi编辑该文件输入Hello World!. 

cd ~/Hello-world
git init
touch README

4、提交原始版本文件

git add README
git commit -m 'first commit'

       将README提交,此时并不影响 远程github的库。

5、PUSH到远程github

git remote add origin https://github.com/username/Hello-World.git
git push origin master

      其中https地址可以在github上找到。

shipley@linux-vo4i:~/Hello-world> git push origin master Username for 'https://github.com': username Password for 'https://hsp8712@github.com': ****** Counting objects: 3, done. Writing objects: 100% (3/3), 216 bytes, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/hsp8712/Hello-world.git  * [new branch]      master -> master

提交成功