您的位置:首页 > 其它

GIT 开始一次旅行 二 (git 本地基本 操作)

2014-01-12 21:57 465 查看
参考 http://rogerdudler.github.io/git-guide/index.zh.html PPT。

http://git-scm.com/book

写的非常的好对于初学git的 童鞋们。

自己/home建立一个git实例:

mkdir git_test

cd git_test

git init

1. 学会clone:

1082 mkdir git_test_2

1083 ls

1084 cd git_test_2/

1085 ls

1086 git clone ~/git_test

2.学会 提交文件

1097 cd git_test

1098 ls

1099 ls -la

1100 vim hello.c

1101 ls

1102 git add hello.c

1103 git log

1104 git show

1105 git commit -m "add hello.c"

1106 git log

1107 git show

3.学会 创建分支,切换分支,显示分支

1109 git checkout -b feature_x

1110 git checkout master

1111 git checkout feature_x

1112 ls

1113 git log

1114 ls

1115 git branch -a

4. 学会 merge 分支 把feature_x 分支 merge 到master上

1126 git checkout feature_x

1127 ls

1128 vim hello.c

1129 git log

1130 ls

1131 git add hello.c

1132 git show

1133 ls

1134 git branch -a

1135 git commit -m "add feature"

1136 git log

1137 git show 257cca

1138 ls

1139 git checkout master

1140 git merge feature_x

1141 git log

1142 git show

5. 解决冲突问题

1149 git checkout master

1150 ls

1151 vim hello.c

1152 git add hello.c

1153 git commit -m "conflict_master"

1154 git show

1155 git checkout feature_x

1156 vim hello.c

1157 git add hello.c

1158 git commit -m "conflicts_feature"

1159 git checkout master

1160 git merge feature_x

1161 git diff master feature_x

1162 ls

1163 git branch -a

1164 vim hello.c

1165 git add hello.c

1166 git merge feature_x

1167 git commit -m "merge OK use master"

1168 git merge feature_x

1169 hitory

1170 history

note:

你懂得。

master branch:

#include <stdio.h>

int main()

{

printf("hello git\n");

printf("hello liuchunhaiadd feature\n");

}

~

feature_x branch

#include <stdio.h>

int main()

{

printf("hello git\n");

printf("hello feature add feature\n");

}

~

~

~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: