创建 git 仓库:
mkdir test
cd test
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/yangzonglei/test.git
git push -u origin master
已有仓库?
cd existing_git_repo
git remote add origin https://gitee.com/yangzonglei/test.git
git push -u origin master
git init 之前要把要添加的文件放到文件夹,否则,只会添加当前目录的直接目录文件 。这种情况是线上仓库是空的。
如果线上仓库有文件的,但是不是一个工程的,就是比如readme文件,init ,clone,然后再添加文件夹,其他都相同
拉去分支
git clone -b develop XXX
之后提交就是指定分支
git clone直接提交用户名密码
git clone直接提交用户名和密码
git使用用户名密码clone的方式:
1 |
|
例如:我的用户名是abc@qq.com,密码是abc123456,git地址为git@xxx.com/www.git
1 |
|
执行报错:
fatal: unable to access 'http://abc@qq.com:abc123456@git.xxx.com/www.git/':
Couldn't resolve host 'qq.com:abc123456@git.xxx.com'
报错原因是因为用户名包含了@符号,所以需求要把@转码一下
<?php
$userame='abc@qq.com';
echo urlencode($userame);
?>
abc%40qq.com
@符号转码后变成了%40,所以只需在clone时将username变为abc%40qq.com即可,再次执行就ok了。
为了防止密码中也可能会有@,我觉得在拼接之前,可以对用户名和密码分别进行编码操作。