先在Coding上创建个项目,并勾选“启用README.md文件初始化项目”。
1.首先需要给项目Project创建个版本库(仓库)
在本地的项目根目录底下,使用 git init 命令把Project变成git可以管理的仓库。
![](https://i-blog.csdnimg.cn/blog_migrate/a09da4eec118bdc890582c4705dd9fd2.webp?x-image-process=image/format,png)
2.把文件放到git仓库
用 git status 命令看仓库的的状态
![](https://i-blog.csdnimg.cn/blog_migrate/94bba9428c6dc1b9cd21e479145026ec.webp?x-image-process=image/format,png)
可以看到第一步只是创建了一个仓库而已,我们还需要把这些未追踪的文件放到仓库里。需要两步
使用(1)git add(把文件添加到仓库) (2) git commit(把文件放到仓库)
![](https://i-blog.csdnimg.cn/blog_migrate/66d87b8c7b6efb39032458de83cecbd0.webp?x-image-process=image/format,png)
3.把本地仓库与Coding上的仓库关联
用 git remote add origin 地址关联
![](https://i-blog.csdnimg.cn/blog_migrate/8c412fccee26bb4a57f9d52372079e30.webp?x-image-process=image/format,png)
![](https://i-blog.csdnimg.cn/blog_migrate/a40209b6cf607abb7cc345cf70195cc2.webp?x-image-process=image/format,png)
4.把本地库的所有内容推送到Coding远程库上
终于来到这一步啦。用 git push origin master 命令
![](https://i-blog.csdnimg.cn/blog_migrate/e0aa1cb27c8f7f9d1f7acb9dd6b148fe.webp?x-image-process=image/format,png)
出错啦,fast-forwards,查了查,按我的理解,这里出错的原因是由于我在Coding创建Project的时候,勾选了启用Readme文件初始化项目,导致远程库有一个Readme文件即非空的仓库,本地必须先把远程的文件pull下来(git pull origin master)然后才能push(git push origin master).
![](https://i-blog.csdnimg.cn/blog_migrate/be8cac88487326aea122373c667e92a6.webp?x-image-process=image/format,png)
ok了,现在远程跟本地的一致了。本地代码的改动随时更新到远程。
![](https://i-blog.csdnimg.cn/blog_migrate/cfb167b12efb90f54d7c6ef220dc2326.webp?x-image-process=image/format,png)
不知道有没走了弯路啊。假如想在另外一台电脑上继续工作,可以用
git clone https://git.coding.net/huang002/Project.git 到电脑上就可以继续工作了吧。