cike0415 发表于 2018-1-10 14:00:11

Gitlab使用总结

Gitlab日常开发流程
  1. 从某一功能分支新建一个自己的开发分支
https://images2015.cnblogs.com/blog/606573/201606/606573-20160627161033421-1302391810.png
  二. 将master分支clone到本地
  

mkdir git-test  
cd git
-test\  
git clone http:
//gitlab.alibaba-inc.com/shanbiao.jsb/temp-code.git  
cd temp-code\
  
ls -lh
  

  三. 切换到自己的开发分支
  

git branch -a  
git checkout new_branch
  

  四. 修改后push到远程仓库
  

git add -A  
git commit
  
git push
  

  五. 在后台发起Merge request
https://images2015.cnblogs.com/blog/606573/201606/606573-20160627162331640-335272547.png
  六. 项目管理员对代码进行review,确定是否accpet merge
  注意:一般开发中是不会直接将自己的开发分支直接合并到master上的,上面仅供测试。

Git常用命令
  1.从本地当前分支创建新分支
  

git checkout -b another_new_branch  

  扩展:

https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gifhttps://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif  

git checkout -b  
usage: git checkout
<branch>  
or: git checkout [
<branch>] -- <file>...  

  

-q, --quiet         suppress progress reporting  

-b <branch>         create and checkout a new branch  

-B <branch>         create/reset and checkout a branch  

-l                  create reflog for new branch  

--detach            detach the HEAD at named commit  

-t, --track         set upstream info for new branch  

--orphan <new branch>  
new unparented branch
  

-2, --ours            checkout our version for unmerged files  

-3, --theirs          checkout their version for unmerged files  

-f, --force         force checkout (throw away local modifications)  

-m, --merge         perform a 3-way merge with the new branch  

--overwrite-ignore    update ignored files (default)  

--conflict <style>    conflict style (merge or diff3)  

-p, --patch         select hunks interactively  

--ignore-skip-worktree-bits  

do not limit pathspecs to sparse entries only  


View Code  2.将本地分支推送到远程仓库
  要想和其他人分享某个本地分支,你需要把它推送到一个你拥有写权限的远程仓库。
  你创建的本地分支不会因为你的写入操作而被自动同步到你引入的远程服务器上,你需要明确地执行推送分支的操作。
  换句话说,对于无意分享的分支,你尽管保留为私人分支好了,而只推送那些协同工作要用到的特性分支。
  如果你有个叫 serverfix 的分支需要和他人一起开发,可以运行 git push (远程仓库名) (分支名):
  

git push origin serverfix  

  3.查看项目日志信息
  

git log --oneline  
页: [1]
查看完整版本: Gitlab使用总结