打开Git Bash。 cd到项目文件夹。(直接把文件夹拖入到bash内即可) 执行初始化代码
git init项目文件夹会产生一个.git的文件夹
格式:
git remote add origin url地址(https或ssh)例如:
git remote add origin git@github.com:rmxob/c--jifenduihuan.git取消关联
git remote rm origin(1)如果在仓库中创建了readme文件,就先pull一下
git pull origin master --allow-unrelated-histories(2)把目标文件/文件夹添加到暂存区 我这是完整的项目,所以用.表示全部
git add .(3)推送至本地数据仓库
git commit -m "frist"(4)推送到github上
git push origin master这样项目就推送到了github上了。
.gitignore 文件:可以在推送时忽略选定的文件。 (1)创建.gitignore文件 可以手动创建,也可以用命令创建
touch .gitignore(2)把不需要推送的文件/文件夹添加到.gitignore文件中 edit .gitignore文件,把文件名添加到gitignore文件就行了。
一般是先有的远程库,从远程库克隆
git clone 远程库的地址