mac电脑 Git远程仓库操作--公司Git操作必备
svn管理模式:集中式

git管理模式:分布式

gitlab:远程仓库
githup:一个网站,提供给用户空间创建git仓库,托管开源代码
gitup想对于很多写过开源代码的都用过,公司的git都在gitlab上管理
下载软件:
mac下载sourcetree(需要越狱)
window需要下载git
具体软件自己自行搜索下载。
下面进行主要是用命令行与远程仓库之间的操作
常用命令
1.克隆远程仓库到本地
$ git clone https://github.com/yanglingyu234/readmeStudy.git
或者用ssh
$ git clone git@github.com:yanglingyu234/readmeStudy.git
克隆结果

2.创建分支
首先进入要创建分支的目录下
$ cd /Users/yanglingyua/gethup/study/readmeStudy
然后查看远程分支
$ git branch -a
查看结果

这是我为了说明新在githup上建的,没有分支。
查看本地分支
$ git branch
运行结果

创建本地分支
$ git branch test
创建分支的分支,后面之要把创建的谁的分支名加上,
例如给test分支创建一个opp的分支
$ git branch opp test
再查看本地分支结果

推送到远程
$ git push origin test
这里需要输入ssh账号密码,我这是githup上的,只要钥匙串点个同意就行了,如下

查看远程结果

切换分支
$ git checkout test
运行结果

相信大家都看明白了✳️号绿色的字,说明当前分支是在编译下的。
添加文件
$ git add /Users/yanglingyua/gethup/study/readmeStudy/“出借”字样排查.xlsx
$ git commit -m"tijiao"
这些基础方法在我的另一个文章里(mac电脑的Git安装和基本操作 )都有,这不做过多说明。
提交到远程
我们不能这样写
$ git push
这样会报错,同时提示我们正确的提交方式,后面加上分支的名字

我在重新写一下
$ git push --set-upstream origin test
提交结果

3.删除分支
如果我直接删除test分支的话会报错,因为我们还在这个分支的编译模式之下。
所以在删除分支之前,先切换分支
$ git checkout master
我这里先切换到主干,然后删除本地分支
$ git branch -d test
这里结果

是说我们删除的分支没有合并到主干
那我们撤回先不删了
$ git branch test 9ee2a74
分支名+SHA1值,9ee2a74就是删除test时,后面括号里的东西。
这是我知道,如果我不知道的话就走
$ git reflog
结果

这样我们就会发现就是删除的 前一次的提交码。因为我们删除的那次形成的编码已经跟test这个分支没有关系了。
然后我们把分支合并到主干
$ git merge test
$ git merge --no-ff test
用--no-ff用于避免test分支中的东西丢失
结果

在删除本地test分支时

删除远程test分支
$ git push origin :test
运行结果

中间的是查看origin位置的方法
$ git remote -v
基本操作就到这里,具体的操作还需要事件,如果后期有用到了随时更新。