【git】 创建一个新分支
2014-02-28 13:39
323 查看
需要创建一个新分支,专门用作为为项目修改后的代码的存储。
参考 http://gitref.justjavac.com/branching/
参考 http://www.cnblogs.com/springbarley/archive/2012/11/03/2752984.html
git branch 可以查看分支:
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git branch
* master
增加一个新分支
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git branch skjni
再次查看分支:
root@Ubuntu32:/home/zhangbin/streaming/live/jni# git branch
* master
skjni
如何切换到新分支呢?
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git branch skjni
fatal: A branch named 'skjni' already exists.
为了避免覆盖(现在的文件与git服务器中的文件大不相同了),新建了一个文件夹:
root@Ubuntu32:/home/zhangbin/streaming/live/jni# mkdir test
root@Ubuntu32:/home/zhangbin/streaming/live//jni# cd test
这个命令是新建并且切换到新分支的,所以报错:
root@Ubuntu32:/home/zhangbin/streaming/live/jni/test# git checkout -b skjni
fatal: A branch named 'skjni' already exists.
切换到新分支:
root@Ubuntu32:/home/zhangbin/streaming/live//jni/test# git checkout skjni
M jni/Android.mk
M jni/Android.mk~
D jni/Untitled Folder/sk_hdi_av.h
D jni/Untitled Folder/sk_hdi_enc.h
D jni/jni-with encode nal ok .rar
等等等等。。。
但是实际上,这些文件实际上没有被下载到本地。
上传现在的代码到git服务器端:
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git add .
warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal',
whose behaviour will change in Git 2.0 with respect to paths you removed.
Paths like 'jni/Untitled Folder/sk_hdi_av.h' that are
removed from your working tree are ignored with this version of Git.
* 'git add --ignore-removal <pathspec>', which is the current default,
ignores paths you removed from your working tree.
* 'git add --all <pathspec>' will let you also record the removals.
Run 'git status' to check the paths you removed from your working tree.
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git commit -m "注释"
[skjni 8798cd2] 注释
40 files changed, 1328 insertions(+), 3013 deletions(-)
create mode 100755 jni/jni_24_1.rar
create mode 100755 jni/jni_24_2.rar
create mode 100755 "jni/jni_24_3\347\254\254\344\270\200\346\254\241\344\271\210\346\234\211\346\255\273\346\234\272.rar"
create mode 100755 "jni/jni\342\200\224\342\200\22424\342\200\224\342\200\2243 \347\254\254\344\270\200\346\254\241\346\262\241\346\234\211\346\255\273\346\234\272.rar"
rewrite jni/live/-live.IAB (62%)
rewrite jni/live/-live.IAD (98%)
rewrite jni/live/-live.IMB (62%)
rewrite jni/live/-live.IMD (93%)
mode change 100644 => 100755 jni/live/liveMedia/FramedSource.cpp
create mode 100755 jni/skjni.IAB
create mode 100755 jni/skjni.IAD
create mode 100755 jni/skjni.IMB
create mode 100755 jni/skjni.IMD
create mode 100755 jni/skjni.PFI
create mode 100755 jni/skjni.PO
create mode 100755 jni/skjni.PR
create mode 100755 jni/skjni.PRI
create mode 100755 jni/skjni.PS
create mode 100755 jni/skjni.SearchResults
create mode 100755 jni/skjni.WK3
rewrite jni/streamer.cpp (80%)
rewrite jni/x264Wrapper.cpp (73%)
上传到skjni分支:
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git push origin skjni
Counting objects: 74, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (44/44), done.
Writing objects: 100% (45/45), 1.96 MiB | 1.24 MiB/s, done.
Total 45 (delta 24), reused 0 (delta 0)
To file:///home/zhangbin/alex/gitProject/meStreamer.git
* [new branch] skjni -> skjni
通过查看gitweb可知:
(1)分支skjni与master并列。
(2)上传到分支skjni后,仅仅上传了与master代码不一样(修改、增加)的几个文件。一样的文件,没有上传到分支。
参考 http://gitref.justjavac.com/branching/
参考 http://www.cnblogs.com/springbarley/archive/2012/11/03/2752984.html
git branch 可以查看分支:
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git branch
* master
增加一个新分支
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git branch skjni
再次查看分支:
root@Ubuntu32:/home/zhangbin/streaming/live/jni# git branch
* master
skjni
如何切换到新分支呢?
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git branch skjni
fatal: A branch named 'skjni' already exists.
为了避免覆盖(现在的文件与git服务器中的文件大不相同了),新建了一个文件夹:
root@Ubuntu32:/home/zhangbin/streaming/live/jni# mkdir test
root@Ubuntu32:/home/zhangbin/streaming/live//jni# cd test
这个命令是新建并且切换到新分支的,所以报错:
root@Ubuntu32:/home/zhangbin/streaming/live/jni/test# git checkout -b skjni
fatal: A branch named 'skjni' already exists.
切换到新分支:
root@Ubuntu32:/home/zhangbin/streaming/live//jni/test# git checkout skjni
M jni/Android.mk
M jni/Android.mk~
D jni/Untitled Folder/sk_hdi_av.h
D jni/Untitled Folder/sk_hdi_enc.h
D jni/jni-with encode nal ok .rar
等等等等。。。
但是实际上,这些文件实际上没有被下载到本地。
上传现在的代码到git服务器端:
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git add .
warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal',
whose behaviour will change in Git 2.0 with respect to paths you removed.
Paths like 'jni/Untitled Folder/sk_hdi_av.h' that are
removed from your working tree are ignored with this version of Git.
* 'git add --ignore-removal <pathspec>', which is the current default,
ignores paths you removed from your working tree.
* 'git add --all <pathspec>' will let you also record the removals.
Run 'git status' to check the paths you removed from your working tree.
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git commit -m "注释"
[skjni 8798cd2] 注释
40 files changed, 1328 insertions(+), 3013 deletions(-)
create mode 100755 jni/jni_24_1.rar
create mode 100755 jni/jni_24_2.rar
create mode 100755 "jni/jni_24_3\347\254\254\344\270\200\346\254\241\344\271\210\346\234\211\346\255\273\346\234\272.rar"
create mode 100755 "jni/jni\342\200\224\342\200\22424\342\200\224\342\200\2243 \347\254\254\344\270\200\346\254\241\346\262\241\346\234\211\346\255\273\346\234\272.rar"
rewrite jni/live/-live.IAB (62%)
rewrite jni/live/-live.IAD (98%)
rewrite jni/live/-live.IMB (62%)
rewrite jni/live/-live.IMD (93%)
mode change 100644 => 100755 jni/live/liveMedia/FramedSource.cpp
create mode 100755 jni/skjni.IAB
create mode 100755 jni/skjni.IAD
create mode 100755 jni/skjni.IMB
create mode 100755 jni/skjni.IMD
create mode 100755 jni/skjni.PFI
create mode 100755 jni/skjni.PO
create mode 100755 jni/skjni.PR
create mode 100755 jni/skjni.PRI
create mode 100755 jni/skjni.PS
create mode 100755 jni/skjni.SearchResults
create mode 100755 jni/skjni.WK3
rewrite jni/streamer.cpp (80%)
rewrite jni/x264Wrapper.cpp (73%)
上传到skjni分支:
root@Ubuntu32:/home/zhangbin/streaming/live//jni# git push origin skjni
Counting objects: 74, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (44/44), done.
Writing objects: 100% (45/45), 1.96 MiB | 1.24 MiB/s, done.
Total 45 (delta 24), reused 0 (delta 0)
To file:///home/zhangbin/alex/gitProject/meStreamer.git
* [new branch] skjni -> skjni
通过查看gitweb可知:
(1)分支skjni与master并列。
(2)上传到分支skjni后,仅仅上传了与master代码不一样(修改、增加)的几个文件。一样的文件,没有上传到分支。
相关文章推荐
- git创建一个新库之后查看分支,创建本地以及远程库分支操作
- 从gitflow 用gitbash创建一个分支并且推送到远程命令行
- git 创建分支单独开发一个新功能,然后合并到dev上的三种方式
- git基于一个分支创建一个新分支
- 【Git】创建一个空分支
- 在GIT中创建一个空分支
- 【Git】创建一个空分支
- 在GIT中创建一个空分支
- git 怎么在master下创建一个新的分支
- git 创建一个新分支,并将一个分支内容复制给创建的新分支
- git 创建一个空分支
- Git历险记(3):创建一个自己的本地仓库
- Git分支 - 创建,切换
- Git查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
- git克隆远程项目并创建本地对应分支
- Git创建repository,以及clone,提交一个repository
- git 创建新分支并推送到远程分支
- git创建与管理远程分支
- git 远程分支创建与推送