git将本地代码 和服务器git@osc 上的代码 关联

 

将本地代码 和服务器git@osc 上的代码 关联

要使用git 首先,你得安装一个git

下载  http://git-scm.com/downloads

安装完成后,需要简单的配置一下,打开 Git Bash

填写用户名和邮箱,会出现在提交记录中,尽量和 git@osc 中保持一致

git config --global user.name "你的名字"
git config --global user.email "你的Email"

 

进入一个本地文件夹,作为待提交目录,初始化

初始化
git init

把该目录下的所有文件全部提交到缓冲区
git add .

第一次提交
git commit -m "first commit"

此时将代码提交到了本地 master 下,还没有提交到服务器

 

添加远程库

移除远程仓库地址
git remove rm origin

添加新的地址
git remote add origin https://git.oschina.net/panie/blog.git

查询当前设置的远程库
git remote -v

 

拉取和提交服务器上的代码

拉取服务器上的代码
git pull origin master

git pull origin master --allow-unrelated-histories


提交本地到服务器

git push origin master

https 方式每次都要输入密码,按照如下设置即可输入一次就不用再手动输入密码

设置记住密码(默认15分钟)
git config --global credential.helper cache

自定义时间(一个小时)
git config credential.helper 'cache --timeout=3600'

长期存储密码
git config --global credential.helper store

 

生成ssh 秘钥

ssh-keygen -t rsa -C "kenie123@163.com"

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值