git命令设置

初始化为git项目:

cd .../project  //切换到项目目录下

git init  //把project初始化为git项目

git remote add origin https://gitee.com/name/project.git  //设置远程项目地址

git remote set-url origin https://gitee.com/name/project.git  //修改远程项目地址

 

首次把项目上传到git上。

1.清空git上的项目。因为上面有个README.md文件

2.使用上面的初始化为git项目命令后再上传

 

//克隆远程项目到当前目录下:

git clone https://gitee.com/name/project.git

 

设置全局用户属性

git config --global user.name "xxx"

git config --global user.email "xxx@xx.com"

设置局部项目用户属性,需要先切换到项目目录下 //如果没设置局部项目的用户属性则默认使用全局的用户属性

git config user.name "xxx"

git config user.email "xxx@xx.com"

根据上面可以发现,设置全局则需要在config后增加 --global,设置局部项目则不需要加

 

设置全局的git长期存储账号密码,如果不设置的话则每次与远程进行交互时都需要输入账号密码

git config --global credential.helper store

也可以设置账号密码有效时间(默认为15分钟)

git config --global credential.helper cache

自定义有效时间,设置有效时间为一小时
git config --global credential.helper cache 'cache --timeout=3600'

 

posted @ 2018-05-24 17:46  Johnson木木  阅读(291)  评论(0编辑  收藏  举报