git 基本操作
远程仓库克隆到本地
git clone ssh://git@xxx
本地修改提交到远程仓库
git add newfile<details>
git commit -m "提交newfile,ps: 这引号内容是备注,必须要有内容"
git push
从远程仓库同步文件到本地
git pull
git分支操作
新建分支并同步到远程仓库
本地新建分支
git branch newBranch //创建分支newBranch
查看分支信息
git log --oneline --decorate --graph --all
切换分支
git checkout newBranch //切换到新分支
将新分支提交到远程仓库
git push origin newBranch //这样才能在远程看到该分支
将本地分支和远程分支关联
git branch --set-upstream-to=origin/newBranch newBranch //这样才能正常的pull和push
合并分支
申请合并
在gitlab上进行操作
审核端
线上解决冲突,务必注意:文件名不能带中文,否则解决冲突显示不出内容
本地git bash合并
git fetch origin //保持与远程同步
git checkout main //切换到main分支
git merge --no-ff newBranch //普通合并分区
git status
查看合并状态,根据status提示将有冲突的文件改写并保存
git add xxx //暂存修改冲突的文件,告诉git你已经解决冲突
git commit //提交合并
此时会出现合并内容提示的窗口,确认无误使用:wq退出即可
git push //推送到远程
完成合并