linux——git安装使用

系统环境centos7
安装git命令
yum install git -y
安装好之后使用命令查看git版本
git –version

[root@bogon ~]# git --version
git version 1.8.3.1

首先在github注册一个帐号,我的帐号名是biaopei,并且在首页找到new repository并点击创建一个项目,我把项目取名为test(我这里用到的是另一个项目mytest,这个test只是用来演示如何找到那个仓库地址而已),其他默认配置进行初始化配置

 


点击上图new repository,取名为test,其它默认,点击创建,会进入下图,下面这个图中的那个链接那里就是仓库地址 

 

 

[root@bogon ~]# git --version
git version 1.8.3.1
[root@bogon ~]# pwd
/root
[root@bogon ~]# ls
anaconda-ks.cfg  Downloads             original-ks.cfg  python
Desktop          initial-setup-ks.cfg  Pictures         Templates
Documents        Music                 Public           Videos
[root@bogon ~]# cd python/
[root@bogon python]# 
[root@bogon python]# git config --global user.name "bp"     //bp这个名字是随便取的,只是用来标记文件更新者而已
[root@bogon python]# git config --global user.email bp1260647530   //邮箱名,这里格式错了,不过没报错,不鸟它
[root@bogon python]# git init     //初始化
Initialized empty Git repository in /root/python/.git/
[root@bogon python]# ls -a   //多了一个.git文件
.   a.py  client.py  dircontent.py  email.py   .git       test.py
..  b.py  c.py       d.py           email.pyc  server.py  what.py
[root@bogon python]# echo "#this is a git test ">>README.md
[root@bogon python]# git add README.md   //上传一个文件
[root@bogon python]# git commit -m "added a README file"  //确认提交,并给文件备注,这时候刷新项目网页也不会显示出来
[master (root-commit) dbee75f] added a README file
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
[root@bogon python]# git remote add origin https://github.com/biaopei/mytest.git    //增加仓库地址
[root@bogon python]# git push -u origin master    //这里才开始登录呢,输入用户名密码,登录成功后,刷新项目网页,就能找到README文件了
Username for 'https://github.com': biaopei
Password for 'https://biaopei@github.com': 
Counting objects: 3, done.
Writing objects: 100% (3/3), 228 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/biaopei/mytest.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
[root@bogon python]# ls
a.py  client.py  dircontent.py  email.py   README.md  test.py
b.py  c.py       d.py           email.pyc  server.py  what.py
[root@bogon python]# git add dircontent.py   //我们现在试着上传dircontent.py到项目中
[root@bogon python]# git commit -m "dircontent.py add notice"
[master 5b1c39e] dircontent.py add notice
 1 file changed, 12 insertions(+)
 create mode 100755 dircontent.py
[root@bogon python]# git push -u origin master  //每次提交都需要登录?
Username for 'https://github.com': biaopei
Password for 'https://biaopei@github.com': 
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 426 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/biaopei/mytest.git
   dbee75f..5b1c39e  master -> master
Branch master set up to track remote branch master from origin.

posted on 2017-10-25 18:06  标配的小号  阅读(124)  评论(0编辑  收藏  举报

导航