Git+Github使用教程

一 配置github

1.注册github账户renle177

2.新建代码库linux-test

以上操作省略...

二 本地操作配置 (linux环境)

1.安装git及配置环境

yum -y install git

git config --global user.name "renle177"

git config --global user.email "380744432@qq.com"

ssh-keygen -t rsa -C "380744432@qq.com"

2.打开www.github.com->Accountsettings->SSH Keys->Add SSH Key->cp id_rsa.pub内容到此

3.创建本地仓库,并push到远程github

mkdir github;cd github

git init                        #初始化

touchREADME                    

git addREADME                  #提交到git本地仓库

git commit -m 'first commit'     #提交文件,并注释信息

git remote add origin git@github.com:renle177/linux-test #连接远程github

git push -u origin master        #更新本地文件到github


git status                      #查看文件状态

git remote -v                   #查看连接的哪个地址

git clone git@github.com:renle177/linux-test #克隆远程仓库到本地

假如本地已经存在了这个项目,而仓库中又有一新的更新,如何把更的合并到本地的项目中?

git fetchorigin                #取得远程更新,这里可以看做是准备要取了

git merge origin/master          #把更新的内容合并到本地分支/master

FAQ:

1.在执行

$ git remote addorigin git@github.com:defnngj/hello-world.git

错误提示:fatal: remote origin already exists.

解决办法:

$ git remote rm origin       #就不会报错误了

2. 在执行

$ git push origin master

错误提示:error:failed to push som refs to.......

解决办法:

$ git pull origin master     #先把远程服务器github上面的文件拉先来,再push 上去。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值