操作纪录 | 上传代码到github

来源:互联网 发布:淘宝有的不能极速退款 编辑:程序博客网 时间:2024/05/17 07:16

前传:
操作纪录 | github注册和windows版git客户端设置

新工程上传代码到github,repository已经创建好。
开始尝试时有一些文件冲突,于是删空本地文件夹将服务器端的repository下载下来再拷贝文件进去上传。

全新项目上传到github

进入项目上层文件夹

cd /d/ongithub

初始化

git init  

获取服务器端代码

git clone git@github.com:dodolo-cc/proxy.git

关联本地仓库与github上的repository

git remote add origin https://github.com/dodolo-cc/proxy

进入项目文件夹

cd proxy

pull,允许不同项目的文件

git pull origin master --allow-unrelated-histories

本地项目文件拷贝进文件夹中

添加所有文件

git add .

commit

git commit -m "upload files"

push

git push -u origin master

可能需要输入github的登录名和密码
至此,本地文件上传到github结束。

修改文件后更新到github

假设修改的是README.md

git add README.mdgit commit -m "add sth in readme"git push

从github删除文件

命令不会删除本地文件

删除文件

git rm --cached filenamegit commit -m "delete file"git push

删除文件夹

git rm --cached -r dirnamegit commit -m "delete directory"git push