方式一:远程仓库没有文件
1
2
3
4
5
| git init(初始化git仓库);
git remote add 地址(设置remote地址);
git add . (将所有变更提交到本地仓库);
git commit -m '' (提交注释);
git push(本地仓库推送到远程仓库)
|
方式二:远程仓库有文件
1
2
3
4
5
6
7
| git init(初始化git仓库);
git remote add origin 地址(设置远程remote地址);
git pull origin master(拉取远程仓库master的文件)
git branch --set-upstream-to=origin/master master(将本地master设置为远程master分支)
git add . (将所有变更提交到本地仓库);
git commit -m '' (提交注释);
git push
|
方式三:
1
2
3
4
5
| git clone 地址(克隆远程仓库) test
cp -r 项目文件 test
git add . (将所有变更提交到本地仓库);
git commit -m '' (提交注释);
git push
|
设置用户和邮箱
一:全局
1
2
| git config --global user.name "you name"
git config --global user.email "you email"
|
二:局部(单个项目)
1
2
| git config user.name "you name"
git config user.email "you email"
|
强制推送