您的位置:首页 > 其它

【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代码不一样(修改、增加)的几个文件。一样的文件,没有上传到分支。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: