git 关联远程库(https协议)

1、在oschina上新建库

2、在本地文件夹右键->"git Bash here"

3、设置全局变量:
git config --global user.name "git账号"
git config --global user.email "git邮箱"

4、初始化本地库
git init

5、关联远程库:
git remote add origin https://git.oschina.net/......git

6、第一次提交(比如新建了一个txt文档):
git add .
git commit -m "提交说明" .
git push -u origin master

(提交期间会要求输入账号、密码)

7、如果忘了拉去最新的代码并且做了修改想要提交,需要暂存修改文件:

git stash  ------------暂存修改工作区

git pull origin maste -----拉去代码

git stash pop  ---------还原工作区

可以通过 touch .gitignore 创建.gitignore 文件,用以忽略不必要的提交文件(如 bin obj等)

原文地址:https://www.cnblogs.com/qk2014/p/6289326.html