好久没有写博客了,今天闲来无事顺便写了一篇,欢迎指正。
以后要多个人协同开发Android ,方便管理代码就自己搭建了一个git服务器,以下是搭建过程:
参考廖大神的官方网站:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137583770360579bc4b458f044ce7afed3df579123eca000
git服务器是Linux的哦
搭建完成后要将自己的项目放上去,步骤:
1.在本地库上使用git remote add 命令:
如 我的服务器是git@xxx:/home/gitrepo,远程库名称origin : git remote add origin git@xxx:/home/gitrepo/learn.git
2.命令git remote -v 查看远程库信息:
git remote -v
origin git@xxx:/home/gitrepo/learn.git (fetch)
origin git@xxx:/home/gitrepo/learn.git (push)
3.关联远程库后,要将本地代码推送到远程库,命令git push:
git push origin master
如果远程库设置了密码,需要输入密码,密码是不显示的,输入后直接回车即可。
如果出现报错 fatal: Couldn't find remote ref master或者fatal: 'origin' does not appear to be a git repository以及fatal: Could not read from remote repository. 需要从第一步重新创建项目,如果报错提示:fatal:remote origin already exists.
需要用命令:git remote rm origin 删除已有的origin 远程库,然后再重新创建远程库。