Git学习与训练
来源:互联网 发布:jquery.rotate.min.js 编辑:程序博客网 时间:2024/05/09 02:40
在gitlab上,每个人需要fork远程分支到自己的目录下,然后在自己的目录下进行开发,开发完成将代码上传到自己的远程仓库,然后通过gitlab服务器发起merge request,同步到主仓库中。为了更快掌握git相关操作,这里设置一项训练,如下:
假设远程仓库为player_oop,本地克隆后为my_player_oop,远程仓库比本地更新,需要同步远程代码到本地,这里不采用git pull的方式,采用如下方法,目的是将下面的命令逐步使用熟练。
- 增加远程分支 git remote add
- 同步远程代码git fetch
- git branch 使用
- git format-patch
- git apply使用
- git am使用
- git st
- git log
- git push
以下是实际操作过程:
#查看当前目录文件root@liufei-VirtualBox:/home/liufei/learngit/abc# lsbuild build.sh bus cfg glue inc install_file patch products public_inc qinPlayerMain.cpp src util#查看当前状态,这里显示落后6个commit,那是因为我已经处理过了,这里只是演示过程root@liufei-VirtualBox:/home/liufei/learngit/abc# git stOn branch masterYour branch is behind 'origin/master' by 6 commits, and can be fast-forwarded. (use "git pull" to update your local branch)#查看当前分支root@liufei-VirtualBox:/home/liufei/learngit/abc# git branch * master#查看远程分支情况root@liufei-VirtualBox:/home/liufei/learngit/abc# git remote -vorigin git@pms.lemon.com:liufei/player_oop.git (fetch)origin git@pms.lemon.com:liufei/player_oop.git (push)#新增远程主仓库路径root@liufei-VirtualBox:/home/liufei/learngit/abc# git remote add upstream git@pms.lemon.com:player/player_oop.git#获取主仓库内容root@liufei-VirtualBox:/home/liufei/learngit/abc# git fetch upstream From pms.lemon.com:player/player_oop * [new branch] master -> upstream/master * [new branch] release -> upstream/release#创建并切换到fork分支root@liufei-VirtualBox:/home/liufei/learngit/abc# git checkout -b forkSwitched to a new branch 'fork'#将远程主仓库中同步到fork分支上,这里使用是rebaseroot@liufei-VirtualBox:/home/liufei/learngit/abc# git rebase upstream/master First, rewinding head to replay your work on top of it...Fast-forwarded fork to upstream/master.#同步完成后的fork分支,对比master分支,创建patch文件,并放置到patch目录下。root@liufei-VirtualBox:/home/liufei/learngit/abc# git format-patch -M master -o patchpatch/0001-add-subtitle-open-close-api.patchpatch/0002-fix-hdmi-spdif-audio-control-add-subtitle-functions.patchpatch/0003-fix-display-zoom-subtitle-bug.patchpatch/0004-31090-fix-default-audioChannel-for-topway.patchpatch/0005-fix-primer-is-the-same-with-live.patchpatch/0006-remove-booking-type-from-player.patch#切换到master分支root@liufei-VirtualBox:/home/liufei/learngit/abc# git checkout master Switched to branch 'master'Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded. (use "git pull" to update your local branch)#检查生成的patch是否OKroot@liufei-VirtualBox:/home/liufei/learngit/abc# git apply --stat patch/*.patch glue/java/java/org/ngb/media/MediaManager.java | 22 ++++---- .../org/ngb/media/SubtitleLanguageControlImpl.java | 10 ++-- glue/java/jni/org_ngb_media_MediaManager.cpp | 57 ++++++++++++++++++++ 3 files changed, 75 insertions(+), 14 deletions(-) bus/client/player_bus_client.c | 38 ++++++++ bus/service/qinPlayerBusServer.cpp | 27 ++++++ glue/java/jni/org_ngb_media_MediaManager.cpp | 2 glue/src/qinMediaPlayerGlue.cpp | 22 ++++- inc/qinDVBPlayer.h | 2 inc/qinPlayerBase.h | 12 +-- inc/qinPlayerUtil.h | 9 ++ public_inc/api/istb_player_api.h | 4 + public_inc/glueapi/qinMediaPlayerGlue.h | 1 public_inc/type/istb_player_type.h | 35 ++++++-- src/qinAudioSetting.cpp | 74 ++++++++++++++-- src/qinDVBPlayer.cpp | 93 +++++++++++++++++--- src/qinPlayerApi.cpp | 39 +++++++- src/qinPlayerResourceManager.cpp | 28 ++++++ src/qinPlayerUtil.cpp | 66 ++++++++++++++ 15 files changed, 399 insertions(+), 53 deletions(-) glue/java/jni/org_ngb_media_MediaManager.cpp | 30 +++--- .../java/jni/org_ngb_util_setting_VideoSetting.cpp | 38 ++++++++ glue/src/qinMediaPlayerGlue.cpp | 95 +++++++++++++++++++- public_inc/glueapi/qinMediaPlayerGlue.h | 2 src/qinDVBPlayer.cpp | 18 +++- 5 files changed, 157 insertions(+), 26 deletions(-) glue/src/qinMediaPlayerGlue.cpp | 12 +-- inc/qinDVBPlayer.h | 3 - public_inc/type/istb_player_type.h | 1 src/qinDVBPlayer.cpp | 78 +++++++++++----- 4 files changed, 60 insertions(+), 34 deletions(-) src/qinDVBPlayer.cpp | 20 +++- 1 file changed, 12 insertions(+), 8 deletions(-) public_inc/type/istb_player_type.h | 67 -------------- 1 file changed, 67 deletions(-)#使用check远程,查看打patch是否成功,这里显示有问题,但是使用git am仍然能打成功,一个疑点???root@liufei-VirtualBox:/home/liufei/learngit/abc# git apply --check --ignore-space-change --ignore-whitespace patch/*.patcherror: patch failed: glue/java/jni/org_ngb_media_MediaManager.cpp:1584error: glue/java/jni/org_ngb_media_MediaMana,ger.cpp: patch does not apply#查看打patch之前的日志,用于确认patch是否打成功root@liufei-VirtualBox:/home/liufei/learngit/abc# git log -1commit 8c39c8137e8265b35eb7c835ff30f7ac5db13f2fAuthor: liu_fei <liu_fei@lemon.com>Date: Tue Jul 19 21:54:16 2016 +0800 fix fcc for gehua#将patch打到master分支root@liufei-VirtualBox:/home/liufei/learngit/abc# git am --ignore-whitespace --ignore-space-change patch/*.patchApplying: add subtitle open & close apiApplying: fix hdmi&spdif audio control, add subtitle functions/home/liufei/learngit/abc/.git/rebase-apply/patch:370: trailing whitespace. ITI_S8 aLanguage[4]; // ISO_639_language_code type. such as: "CHN". /home/liufei/learngit/abc/.git/rebase-apply/patch:873: trailing whitespace./home/liufei/learngit/abc/.git/rebase-apply/patch:973: trailing whitespace. return result; /home/liufei/learngit/abc/.git/rebase-apply/patch:975: new blank line at EOF.+warning: 4 lines add whitespace errors.Applying: fix display zoom && subtitle bugApplying: #31090, fix default audioChannel for topwayApplying: fix primer is the same with liveApplying: remove booking type from player#查看打完patch之后的日志情况root@liufei-VirtualBox:/home/liufei/learngit/abc# git logcommit 81f2eafcbf95f8b349183c0ef49c84395edefa6eAuthor: lzy <lzy@lemon.com>Date: Wed Jul 27 10:10:30 2016 +0800 remove booking type from playercommit c7dd5709753a6f839166c6d8752d9d08522f9cf8Author: lzy <lzy@lemon.com>Date: Tue Jul 26 18:00:38 2016 +0800 fix primer is the same with livecommit fd9c9795b294dc51d3d3519f47ca0b1e59a9f5bfAuthor: lzy <lzy@lemon.com>Date: Sat Jul 23 19:05:36 2016 +0800 #31090, fix default audioChannel for topwaycommit 7e59503fe8783d1e076c0960b27e5dc5f3f7fce9Author: lzy <lzy@lemon.com>Date: Fri Jul 22 19:29:14 2016 +0800 fix display zoom && subtitle bugcommit 880885f2ca11543810fbbd627f8fa224e1f54e29Author: lzy <lzy@lemon.com>Date: Thu Jul 21 21:12:18 2016 +0800 fix hdmi&spdif audio control, add subtitle functionscommit c6aed80b84531fdf47a5a3a00b05b9dbc6d44b1dAuthor: lzy <lzy@lemon.com>Date: Thu Jul 21 19:59:42 2016 +0800 add subtitle open & close apicommit 8c39c8137e8265b35eb7c835ff30f7ac5db13f2fAuthor: liu_fei <liu_fei@lemon.com>Date: Tue Jul 19 21:54:16 2016 +0800 fix fcc for gehua
0 0
- Git学习与训练
- Git学习与训练
- GIT 学习与使用
- git 学习与使用
- git学习与使用
- git学习与使用
- 学习git与github
- git学习与使用
- caffe学习之训练与测试minst
- 高考与机器学习训练测试
- caffe 学习笔记-模型训练与测试
- 【git】git常用命令的学习与总结
- linux与git学习日志
- git资源与学习笔记
- git的学习与使用
- Git学习与总结一
- Git学习与总结二
- Git学习与总结三
- 监听电池电量之粘性广播
- 关于FREEMARKER的一些总结
- 日期功能类DateFunction
- APK--瘦身之路--减小软件大小
- SQL Server:字符串函数
- Git学习与训练
- 历史sql plan
- iOS - 大文件下载(task and session)
- C++ text file process summary
- HTML5 codecademy CSS文件
- C/C++中声明指针变量时星号是靠近变量名还是靠近类型?
- C语言程序设计谭浩强版 二
- 河南多校暑期集训-Catch That Cow(广搜)
- js学习笔记